r267: Really fix the segfault. Hand the brown paper bag, please
[nbd.git] / nbd-server.c
index 85a1e06..a7f759f 100644 (file)
@@ -1323,6 +1323,9 @@ void destroy_pid_t(gpointer data) {
 void daemonize(SERVER* serve) {
        FILE*pidf;
 
+       if(serve && !(serve->port)) {
+               return;
+       }
        if(daemon(0,0)<0) {
                err("daemon");
        }
@@ -1544,31 +1547,28 @@ int main(int argc, char *argv[]) {
        }
        if(serve) {
                g_array_append_val(servers, *serve);
-       }
-
-/* We don't support this at this time */
-#if 0
-       if (!(serve->port)) {
-               CLIENT *client;
+     
+               if (!(serve->port)) {
+                       CLIENT *client;
 #ifndef ISSERVER
-               /* You really should define ISSERVER if you're going to use
-                * inetd mode, but if you don't, closing stdout and stderr
-                * (which inetd had connected to the client socket) will let it
-                * work. */
-               close(1);
-               close(2);
-               open("/dev/null", O_WRONLY);
-               open("/dev/null", O_WRONLY);
-#endif
-               client=g_malloc(sizeof(CLIENT));
-               client->server=serve;
-               client->net=0;
-               client->exportsize=OFFT_MAX;
-               set_peername(0,client);
-               serveconnection(client);
-               return 0;
-        }
+                       /* You really should define ISSERVER if you're going to use
+                        * inetd mode, but if you don't, closing stdout and stderr
+                        * (which inetd had connected to the client socket) will let it
+                        * work. */
+                       close(1);
+                       close(2);
+                       open("/dev/null", O_WRONLY);
+                       open("/dev/null", O_WRONLY);
 #endif
+                       client=g_malloc(sizeof(CLIENT));
+                       client->server=serve;
+                       client->net=0;
+                       client->exportsize=OFFT_MAX;
+                       set_peername(0,client);
+                       serveconnection(client);
+                       return 0;
+               }
+       }
        if((!serve) && (!servers||!servers->len)) {
                g_message("Nothing to do! Bye!");
                exit(EXIT_FAILURE);