[Spice-devel] [PATCH 11/18] Move exit_on_disconnect to RedsState struct

Frediano Ziglio fziglio at redhat.com
Tue Feb 2 17:06:00 CET 2016


From: Jonathon Jongsma <jjongsma at redhat.com>

Removing more global variables
---
 server/reds-private.h | 1 +
 server/reds.c         | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/server/reds-private.h b/server/reds-private.h
index 9c3db70..5042773 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -224,6 +224,7 @@ struct RedsState {
     gboolean agent_mouse;
     gboolean agent_copypaste;
     gboolean agent_file_xfer;
+    gboolean exit_on_disconnect;
 };
 
 #endif
diff --git a/server/reds.c b/server/reds.c
index f3268d6..b25a1be 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -146,7 +146,6 @@ static SpiceCoreInterfaceInternal core_interface_adapter = {
 
 static pthread_mutex_t *lock_cs;
 static long *lock_count;
-static bool exit_on_disconnect = FALSE;
 
 RedsState *reds = NULL;
 
@@ -458,7 +457,7 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
 {
     RedsMigTargetClient *mig_client;
 
-    if (exit_on_disconnect)
+    if (reds->exit_on_disconnect)
     {
         spice_info("Exiting server because of client disconnect.\n");
         exit(0);
@@ -3428,6 +3427,7 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
     reds->agent_mouse = TRUE;
     reds->agent_copypaste = TRUE;
     reds->agent_file_xfer = TRUE;
+    reds->exit_on_disconnect = FALSE;
     return reds;
 }
 
@@ -3540,7 +3540,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_listen_socket_fd(SpiceServer *s, int lis
 SPICE_GNUC_VISIBLE int spice_server_set_exit_on_disconnect(SpiceServer *s, int flag)
 {
     spice_assert(reds == s);
-    exit_on_disconnect = !!flag;
+    s->exit_on_disconnect = !!flag;
     return 0;
 }
 
-- 
2.4.3



More information about the Spice-devel mailing list