Commit e7c827d5 authored by Silvio Lazzeretti's avatar Silvio Lazzeretti Committed by Ignacio Casal Quinteiro
Browse files

websocket-connection: do not send new frames until the previous is not successfully sent

If the sending of a frame fails with G_IO_ERROR_WOULD_BLOCK,
we must send it again before sending more urgent ones.
This change is relevant in case a SSL connection is being used
because SSL expects the same message to be resent

https://bugzilla.gnome.org/show_bug.cgi?id=790436
parent d17d5ee2
......@@ -107,6 +107,7 @@ typedef struct {
gsize sent;
gsize amount;
SoupWebsocketQueueFlags flags;
gboolean pending;
} Frame;
struct _SoupWebsocketConnectionPrivate {
......@@ -971,6 +972,9 @@ on_web_socket_output (GObject *pollable_stream,
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
g_clear_error (&error);
count = 0;
g_debug ("failed to send frame because it would block, marking as pending");
frame->pending = TRUE;
} else {
emit_error_and_close (self, error, TRUE);
return FALSE;
......@@ -1034,12 +1038,12 @@ queue_frame (SoupWebsocketConnection *self,
if (flags & SOUP_WEBSOCKET_QUEUE_URGENT) {
GList *l;
/* Find out the first frame that is not urgent or partially sent */
/* Find out the first frame that is not urgent or partially sent or pending */
for (l = g_queue_peek_head_link (&pv->outgoing); l != NULL; l = l->next) {
Frame *prev = l->data;
if (!(prev->flags & SOUP_WEBSOCKET_QUEUE_URGENT) &&
prev->sent == 0)
prev->sent == 0 && !prev->pending)
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment