Code

sysdbd: Keep connections open during reconfiguration.
authorSebastian Harl <sh@tokkee.org>
Mon, 21 Apr 2014 18:23:15 +0000 (20:23 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 21 Apr 2014 18:23:15 +0000 (20:23 +0200)
By using the new sdb_fe_sock_clear_listeners(), the list of active listeners
may be reconfigured without affecting any open connections.

src/tools/sysdbd/main.c

index 4a4d55ec0ec9eb6e57abb7dcd501be923c0f8c86..3be49381e43f2bc37686b01ae60672e58e2baef2 100644 (file)
@@ -232,6 +232,8 @@ backend_handler(void __attribute__((unused)) *data)
 static int
 main_loop(void)
 {
+       sdb_fe_socket_t *sock = sdb_fe_sock_create();
+
        pthread_t backend_thread;
 
        while (42) {
@@ -251,7 +253,6 @@ main_loop(void)
                        break;
                }
 
-               sdb_fe_socket_t *sock = sdb_fe_sock_create();
                for (i = 0; i < listen_addresses_num; ++i)
                        if (sdb_fe_sock_add_listener(sock, listen_addresses[i]))
                                break;
@@ -266,17 +267,19 @@ main_loop(void)
                 * and make the thread shut down faster */
                pthread_kill(backend_thread, SIGINT);
                pthread_join(backend_thread, NULL);
-               sdb_fe_sock_destroy(sock);
 
                if (! reconfigure)
                        break;
 
                reconfigure = 0;
+               sdb_fe_sock_clear_listeners(sock);
                if (do_reconfigure()) {
                        sdb_log(SDB_LOG_ERR, "Reconfiguration failed");
                        break;
                }
        }
+
+       sdb_fe_sock_destroy(sock);
        return 0;
 } /* main_loop */