[Spice-commits] 6 commits - server/red-channel-client.c server/red-stream.c server/stream-channel.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Dec 4 12:17:21 UTC 2019


 server/red-channel-client.c |   90 ++++++++++++++++++++------------------------
 server/red-stream.c         |    6 --
 server/stream-channel.c     |    1 
 3 files changed, 43 insertions(+), 54 deletions(-)

New commits:
commit 51d94040b25550491b62ecce1554ee07b0207a95
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Nov 15 15:16:51 2019 +0000

    red-channel-client: Fix typo in comment
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index eb580431..c0b2e735 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -682,13 +682,13 @@ static void red_channel_client_ping_timer(void *opaque)
 #ifdef HAVE_LINUX_SOCKIOS_H /* SIOCOUTQ is a Linux only ioctl on sockets. */
     int so_unsent_size = 0;
 
-    /* retrieving the occupied size of the socket's tcp snd buffer (unacked + unsent) */
+    /* retrieving the occupied size of the socket's tcp send buffer (unacked + unsent) */
     if (ioctl(rcc->priv->stream->socket, SIOCOUTQ, &so_unsent_size) == -1) {
         red_channel_warning(red_channel_client_get_channel(rcc),
                             "ioctl(SIOCOUTQ) failed, %s", strerror(errno));
     }
     if (so_unsent_size > 0) {
-        /* tcp snd buffer is still occupied. rescheduling ping */
+        /* tcp send buffer is still occupied. rescheduling ping */
         red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS);
         return;
     }
commit 2ca660a2f97a70230ae3de50ea5c6977db535e25
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 14 12:36:46 2019 +0000

    stream-channel: Remove default property
    
    "monitor-latency" is FALSE by default.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/server/stream-channel.c b/server/stream-channel.c
index cc0eae5d..9841ff66 100644
--- a/server/stream-channel.c
+++ b/server/stream-channel.c
@@ -189,7 +189,6 @@ stream_channel_client_new(StreamChannel *channel, RedClient *client, RedStream *
                          "channel", channel,
                          "client", client,
                          "stream", stream,
-                         "monitor-latency", FALSE,
                          "caps", caps,
                          NULL);
 
commit 3b9d1eadf7d93e4db96d6ea00752c8eaa042eaab
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 14 11:45:04 2019 +0000

    red-channel-client: Fix indentation
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 5246fad8..eb580431 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -754,7 +754,7 @@ static void red_channel_client_connectivity_timer(void *opaque)
                    rcc->priv->latency_monitor.state == PING_STATE_LATENCY) {
             monitor->state = CONNECTIVITY_STATE_WAIT_PONG;
         } else {
-             monitor->state = CONNECTIVITY_STATE_CONNECTED;
+            monitor->state = CONNECTIVITY_STATE_CONNECTED;
         }
         red_timer_start(monitor->timer, monitor->timeout);
     } else {
commit ac41e6097a0837222f1f8ddcb46a0b421b8e6bf2
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 14 11:44:45 2019 +0000

    red-channel-client: Reuse "monitor" variable
    
    "&rcc->priv->connectivity_monitor" is cached in "monitor" variable.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 4bd0b7b7..5246fad8 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -756,8 +756,7 @@ static void red_channel_client_connectivity_timer(void *opaque)
         } else {
              monitor->state = CONNECTIVITY_STATE_CONNECTED;
         }
-        red_timer_start(rcc->priv->connectivity_monitor.timer,
-                          rcc->priv->connectivity_monitor.timeout);
+        red_timer_start(monitor->timer, monitor->timeout);
     } else {
         monitor->state = CONNECTIVITY_STATE_DISCONNECTED;
         red_channel_warning(rcc->priv->channel,
commit 0fc5af3a06f0163074e1e8a5046398247202df8c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 14 11:22:36 2019 +0000

    Do not check for NULL calling red_watch_remove and red_timer_remove
    
    These functions already check for NULL.
    They are used mainly for cleanup, so cold path of code so speed
    in case of NULL is not important (and usually should not be NULL).
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 91c6ab1b..4bd0b7b7 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -326,14 +326,11 @@ red_channel_client_finalize(GObject *object)
 {
     RedChannelClient *self = RED_CHANNEL_CLIENT(object);
 
-    if (self->priv->latency_monitor.timer) {
-        red_timer_remove(self->priv->latency_monitor.timer);
-        self->priv->latency_monitor.timer = NULL;
-    }
-    if (self->priv->connectivity_monitor.timer) {
-        red_timer_remove(self->priv->connectivity_monitor.timer);
-        self->priv->connectivity_monitor.timer = NULL;
-    }
+    red_timer_remove(self->priv->latency_monitor.timer);
+    self->priv->latency_monitor.timer = NULL;
+
+    red_timer_remove(self->priv->connectivity_monitor.timer);
+    self->priv->connectivity_monitor.timer = NULL;
 
     red_stream_free(self->priv->stream);
     self->priv->stream = NULL;
@@ -1010,15 +1007,13 @@ bool red_channel_client_is_waiting_for_migrate_data(RedChannelClient *rcc)
 
 void red_channel_client_default_migrate(RedChannelClient *rcc)
 {
-    if (rcc->priv->latency_monitor.timer) {
-        red_channel_client_cancel_ping_timer(rcc);
-        red_timer_remove(rcc->priv->latency_monitor.timer);
-        rcc->priv->latency_monitor.timer = NULL;
-    }
-    if (rcc->priv->connectivity_monitor.timer) {
-        red_timer_remove(rcc->priv->connectivity_monitor.timer);
-        rcc->priv->connectivity_monitor.timer = NULL;
-    }
+    red_channel_client_cancel_ping_timer(rcc);
+    red_timer_remove(rcc->priv->latency_monitor.timer);
+    rcc->priv->latency_monitor.timer = NULL;
+
+    red_timer_remove(rcc->priv->connectivity_monitor.timer);
+    rcc->priv->connectivity_monitor.timer = NULL;
+
     red_channel_client_pipe_add_type(rcc, RED_PIPE_ITEM_TYPE_MIGRATE);
 }
 
@@ -1724,18 +1719,16 @@ void red_channel_client_disconnect(RedChannelClient *rcc)
         return;
     }
     red_channel_client_pipe_clear(rcc);
-    if (rcc->priv->stream->watch) {
-        red_watch_remove(rcc->priv->stream->watch);
-        rcc->priv->stream->watch = NULL;
-    }
-    if (rcc->priv->latency_monitor.timer) {
-        red_timer_remove(rcc->priv->latency_monitor.timer);
-        rcc->priv->latency_monitor.timer = NULL;
-    }
-    if (rcc->priv->connectivity_monitor.timer) {
-        red_timer_remove(rcc->priv->connectivity_monitor.timer);
-        rcc->priv->connectivity_monitor.timer = NULL;
-    }
+
+    red_watch_remove(rcc->priv->stream->watch);
+    rcc->priv->stream->watch = NULL;
+
+    red_timer_remove(rcc->priv->latency_monitor.timer);
+    rcc->priv->latency_monitor.timer = NULL;
+
+    red_timer_remove(rcc->priv->connectivity_monitor.timer);
+    rcc->priv->connectivity_monitor.timer = NULL;
+
     red_channel_remove_client(channel, rcc);
     red_channel_client_on_disconnect(rcc);
 }
diff --git a/server/red-stream.c b/server/red-stream.c
index aec482fb..2c13aa2f 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -212,10 +212,8 @@ static ssize_t stream_ssl_read_cb(RedStream *s, void *buf, size_t size)
 
 void red_stream_remove_watch(RedStream* s)
 {
-    if (s->watch) {
-        red_watch_remove(s->watch);
-        s->watch = NULL;
-    }
+    red_watch_remove(s->watch);
+    s->watch = NULL;
 }
 
 #if HAVE_SASL
commit 250d4480ff31f47312b4415ba784522dfbda3b79
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 14 11:02:36 2019 +0000

    red-channel-client: Reduce indentation in red_channel_client_handle_outgoing
    
    When write fails, all cases of the switch are handled.
    Make this clear.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index d6c334ee..91c6ab1b 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1094,29 +1094,29 @@ static void red_channel_client_handle_outgoing(RedChannelClient *rcc)
             switch (errno) {
             case EAGAIN:
                 red_channel_client_set_blocked(rcc);
-                return;
+                break;
             case EINTR:
                 continue;
             case EPIPE:
                 red_channel_client_disconnect(rcc);
-                return;
+                break;
             default:
                 red_channel_warning(red_channel_client_get_channel(rcc), "%s", strerror(errno));
                 red_channel_client_disconnect(rcc);
-                return;
-            }
-        } else {
-            buffer->pos += n;
-            red_channel_client_data_sent(rcc, n);
-            if (buffer->pos == buffer->size) { // finished writing data
-                /* reset buffer before calling on_msg_done, since it
-                 * can trigger another call to red_channel_client_handle_outgoing (when
-                 * switching from the urgent marshaller to the main one */
-                buffer->pos = 0;
-                buffer->size = 0;
-                red_channel_client_msg_sent(rcc);
-                return;
+                break;
             }
+            return;
+        }
+        buffer->pos += n;
+        red_channel_client_data_sent(rcc, n);
+        if (buffer->pos == buffer->size) { // finished writing data
+            /* reset buffer before calling on_msg_done, since it
+             * can trigger another call to red_channel_client_handle_outgoing (when
+             * switching from the urgent marshaller to the main one */
+            buffer->pos = 0;
+            buffer->size = 0;
+            red_channel_client_msg_sent(rcc);
+            return;
         }
     }
 }


More information about the Spice-commits mailing list