summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Lazzeretti <silviola@amazon.com>2018-01-24 11:23:34 +0100
committerIgnacio Casal Quinteiro <qignacio@amazon.com>2018-01-24 11:24:15 +0100
commite7c827d5979ce6da64f8722254a315960bcf08c2 (patch)
tree37d35c50a762ebf3c6344ddc692fbdfedca0a72b
parentd17d5ee2d05a658038e7313fd4fc587525ba37ad (diff)
downloadlibsoup-e7c827d5979ce6da64f8722254a315960bcf08c2.tar.gz
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
-rw-r--r--libsoup/soup-websocket-connection.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libsoup/soup-websocket-connection.c b/libsoup/soup-websocket-connection.c
index 369c2234..b93fab2a 100644
--- a/libsoup/soup-websocket-connection.c
+++ b/libsoup/soup-websocket-connection.c
@@ -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;
}