[spice-gtk,v2,4/5] webdav: remove client on empty message

Submitted by Jakub Janku on June 19, 2019, 3:37 p.m.

Details

Message ID 20190619153750.29921-4-jjanku@redhat.com
State Accepted
Commit a7850b432ad53c8a697aac84a7a10c243576f517
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Jakub Janku June 19, 2019, 3:37 p.m.
Message with no data from spice-webdav daemon means
the client disconnected.

In this case, the client connection to phodav
should be closed as well.

This can happen e.g. when file transfer gets cancelled.

Also, while we're at it, reorder the code a bit.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
---
 src/channel-webdav.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/channel-webdav.c b/src/channel-webdav.c
index 4e08efa..a8cdcbc 100644
--- a/src/channel-webdav.c
+++ b/src/channel-webdav.c
@@ -335,15 +335,15 @@  static void demux_to_client(Client *client)
 
     CHANNEL_DEBUG(client->self, "pushing %"G_GSIZE_FORMAT" to client %p", size, client);
 
-    if (size > 0) {
-        g_output_stream_write_all_async(g_io_stream_get_output_stream(client->pipe),
-                                        c->demux.buf, size, G_PRIORITY_DEFAULT,
-                                        c->cancellable, demux_to_client_cb, client);
+    if (size == 0) {
+        /* Client disconnected */
+        demux_to_client_finish(client, TRUE);
         return;
-    } else {
-        /* Nothing to write */
-        demux_to_client_finish(client, FALSE);
     }
+
+    g_output_stream_write_all_async(g_io_stream_get_output_stream(client->pipe),
+                                    c->demux.buf, size, G_PRIORITY_DEFAULT,
+                                    c->cancellable, demux_to_client_cb, client);
 #endif
 }