Code

daemon: Exit if adding a listener fails.
authorSebastian Harl <sh@tokkee.org>
Tue, 22 Oct 2013 07:08:37 +0000 (09:08 +0200)
committerSebastian Harl <sh@tokkee.org>
Tue, 22 Oct 2013 07:08:37 +0000 (09:08 +0200)
src/daemon/sysdbd.c

index 6e75c039bb21f1f5761df3f1e363b13b8f7136fe..072807dc84611ec26df49beb157cbe72a67ccf31 100644 (file)
@@ -273,10 +273,16 @@ main(int argc, char **argv)
 
                sdb_fe_socket_t *sock = sdb_fe_sock_create();
                for (i = 0; i < listen_addresses_num; ++i)
-                       sdb_fe_sock_add_listener(sock, listen_addresses[i]);
-               sdb_fe_sock_listen_and_serve(sock, &frontend_main_loop);
+                       if (sdb_fe_sock_add_listener(sock, listen_addresses[i]))
+                               break;
+
+               /* break on error */
+               if (i >= listen_addresses_num)
+                       sdb_fe_sock_listen_and_serve(sock, &frontend_main_loop);
 
+               plugin_main_loop.do_loop = 0;
                pthread_join(backend_thread, NULL);
+               sdb_fe_sock_destroy(sock);
        }
 
        sdb_log(SDB_LOG_INFO, "Shutting down SysDB daemon "SDB_VERSION_STRING