[Spice-devel] [PATCH 12/15] Move spice_port to RedsState struct

Frediano Ziglio fziglio at redhat.com
Thu Jan 21 08:16:27 PST 2016


From: Jonathon Jongsma <jjongsma at redhat.com>

Remove another global variable
---
 server/reds-private.h | 1 +
 server/reds.c         | 8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/server/reds-private.h b/server/reds-private.h
index 7a3b524..7f1a6df 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -198,6 +198,7 @@ struct RedsState {
     const char *default_renderer;
     GArray *renderers;
 
+    int spice_port;
 };
 
 #endif
diff --git a/server/reds.c b/server/reds.c
index 6f3d9a7..bb5df6a 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -149,7 +149,6 @@ static SpiceMigrateInstance *migration_interface = NULL;
 
 static TicketAuthentication taTicket;
 
-static int spice_port = -1;
 static int spice_secure_port = -1;
 static int spice_listen_socket_fd = -1;
 static char spice_addr[256];
@@ -2568,8 +2567,8 @@ void reds_set_client_mm_time_latency(RedsState *reds, RedClient *client, uint32_
 
 static int reds_init_net(RedsState *reds)
 {
-    if (spice_port != -1 || spice_family == AF_UNIX) {
-        reds->listen_socket = reds_init_socket(spice_addr, spice_port, spice_family);
+    if (reds->spice_port != -1 || spice_family == AF_UNIX) {
+        reds->listen_socket = reds_init_socket(spice_addr, reds->spice_port, spice_family);
         if (-1 == reds->listen_socket) {
             return -1;
         }
@@ -3447,6 +3446,7 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
         SPICE_CHANNEL_SECURITY_NONE | SPICE_CHANNEL_SECURITY_SSL;
     reds->default_renderer = "sw";
     reds->renderers = g_array_sized_new(FALSE, TRUE, sizeof(uint32_t), RED_RENDERER_LAST);
+    reds->spice_port = -1;
     return reds;
 }
 
@@ -3528,7 +3528,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_port(SpiceServer *s, int port)
     if (port < 0 || port > 0xffff) {
         return -1;
     }
-    spice_port = port;
+    s->spice_port = port;
     return 0;
 }
 
-- 
2.4.3



More information about the Spice-devel mailing list