[xiph-cvs] cvs commit: icecast/src main.c

Michael Smith msmith at xiph.org
Fri Aug 9 06:14:59 PDT 2002



msmith      02/08/09 09:14:59

  Modified:    src      main.c
  Log:
  Fix crash when socket couldn't be bound.

Revision  Changes    Path
1.14      +11 -4     icecast/src/main.c

Index: main.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/main.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- main.c	9 Aug 2002 08:11:37 -0000	1.13
+++ main.c	9 Aug 2002 13:14:59 -0000	1.14
@@ -150,17 +150,19 @@
 }
 
 /* bind the socket and start listening */
-static void _server_proc_init(void)
+static int _server_proc_init(void)
 {
         if (!_setup_socket()) {
                 fprintf(stderr, "Could not create listener socket on port %d\n", config_get_config()->port);
-		return;
+		return 0;
         }
 
         if (!_start_listening()) {
                 fprintf(stderr, "Failed trying to listen on server socket\n");
-		return;
+		return 0;
         }
+
+    return 1;
 }
 
 /* this is the heart of the beast */
@@ -291,7 +293,12 @@
         /* override config file options with commandline options */
         config_parse_cmdline(argc, argv);
 
-    _server_proc_init(); /* Bind socket, before we change userid */
+    /* Bind socket, before we change userid */
+    if(!_server_proc_init()) {
+        fprintf(stderr, "Server startup failed. Exiting.\n");
+        _shutdown_subsystems();
+        return 1;
+    }
 
     _ch_root_uid_setup(); /* Change user id and root if requested/possible */
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list