From: Sebastian Harl Date: Mon, 21 Apr 2014 18:23:15 +0000 (+0200) Subject: sysdbd: Keep connections open during reconfiguration. X-Git-Tag: sysdb-0.1.0~103 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=53a8fb0fcbfdd6df1fb688df6a5c3a6cc99f6a3d;p=sysdb.git sysdbd: Keep connections open during reconfiguration. By using the new sdb_fe_sock_clear_listeners(), the list of active listeners may be reconfigured without affecting any open connections. --- diff --git a/src/tools/sysdbd/main.c b/src/tools/sysdbd/main.c index 4a4d55e..3be4938 100644 --- a/src/tools/sysdbd/main.c +++ b/src/tools/sysdbd/main.c @@ -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 */