[PATCH vdagent v2 5/8] vdagent: small refactor on udscs setup function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

This is mostly a preparatory patch to reduce the usage of globals and
the GMainLoop integration. The changes target one function by:

* Changing its name from client_setup() to client_setup_sync(): As it
  important to clarify that the function block;

* Removing the 'reconnect' argument as the input is the global
  'do_daemonize'. We can use the global here as it is related to
  command line options;

* Changing the return value from 'int' to 'udscs_connection *' as the
  followup patch will remove the global variable 'client'.

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
 src/vdagent/vdagent.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
index 0bb631f..ac6e732 100644
--- a/src/vdagent/vdagent.c
+++ b/src/vdagent/vdagent.c
@@ -230,18 +230,20 @@ static void daemon_read_complete(struct udscs_connection **connp,
     }
 }
 
-static int client_setup(int reconnect)
+static struct udscs_connection *client_setup_sync(void)
 {
+    struct udscs_connection *conn = NULL;
+
     while (!quit) {
-        client = udscs_connect(vdagentd_socket, daemon_read_complete, NULL,
-                               vdagentd_messages, VDAGENTD_NO_MESSAGES,
-                               debug);
-        if (client || !reconnect || quit) {
+        conn = udscs_connect(vdagentd_socket, daemon_read_complete, NULL,
+                             vdagentd_messages, VDAGENTD_NO_MESSAGES,
+                             debug);
+        if (conn || !do_daemonize || quit) {
             break;
         }
         sleep(1);
     }
-    return client == NULL;
+    return conn;
 }
 
 static void quit_handler(int sig)
@@ -360,7 +362,8 @@ reconnect:
         execvp(argv[0], argv);
     }
 
-    if (client_setup(do_daemonize)) {
+    client = client_setup_sync();
+    if (client == NULL) {
         return 1;
     }
 
-- 
2.13.6

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]