[Freeswitch-svn] [commit] r9796 - in freeswitch/trunk: libs/xmlrpc-c/include/xmlrpc-c libs/xmlrpc-c/lib/abyss/src src src/mod/formats/mod_shout src/mod/xml_int/mod_xml_rpc

Freeswitch SVN anthm at freeswitch.org
Thu Oct 2 14:50:10 EDT 2008


Author: anthm
Date: Thu Oct  2 14:50:09 2008
New Revision: 9796

Modified:
   freeswitch/trunk/libs/xmlrpc-c/include/xmlrpc-c/abyss.h
   freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/server.c
   freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_unix.c
   freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_win.c
   freeswitch/trunk/src/mod/formats/mod_shout/Makefile
   freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
   freeswitch/trunk/src/switch.c

Log:
fix xml_rpc socket shutdown

Modified: freeswitch/trunk/libs/xmlrpc-c/include/xmlrpc-c/abyss.h
==============================================================================
--- freeswitch/trunk/libs/xmlrpc-c/include/xmlrpc-c/abyss.h	(original)
+++ freeswitch/trunk/libs/xmlrpc-c/include/xmlrpc-c/abyss.h	Thu Oct  2 14:50:09 2008
@@ -191,7 +191,7 @@
 ServerSetMimeType(TServer *  const serverP,
                   MIMEType * const MIMETypeP);
 
-void
+int
 ServerInit(TServer * const serverP);
 
 void

Modified: freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/server.c
==============================================================================
--- freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/server.c	(original)
+++ freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/server.c	Thu Oct  2 14:50:09 2008
@@ -42,12 +42,12 @@
 
     srvP->terminationRequested = true;
 
-    if (srvP->chanSwitchP)
+    if (srvP->chanSwitchP) {
         ChanSwitchInterrupt(srvP->chanSwitchP);
+        ChanSwitchDestroy(srvP->chanSwitchP);
+	}
 }
 
-
-
 void
 ServerResetTerminate(TServer * const serverP) {
 
@@ -651,7 +651,7 @@
 
 
 
-void
+int
 ServerInit(TServer * const serverP) {
 /*----------------------------------------------------------------------------
    Initialize a server to accept connections.
@@ -700,9 +700,11 @@
     }
     if (retError) {
         TraceMsg("ServerInit() failed.  %s", retError);
-        exit(1);
+		return 0;
         xmlrpc_strfree(retError);
     }
+
+	return 1;
 }
 
 

Modified: freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_unix.c
==============================================================================
--- freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_unix.c	(original)
+++ freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_unix.c	Thu Oct  2 14:50:09 2008
@@ -40,7 +40,7 @@
 
 #include "socket_unix.h"
 
-#define sane_close(_it) if (_it > -1) {close(_it) ; _it = -1; }
+#define sane_close(_it) do {if (_it > -1) { close(_it) ; _it = -1; }} while (_it > -1)
 
 typedef struct {
     int interruptorFd;
@@ -849,6 +849,7 @@
 
     struct sockaddr_in name;
     int rc;
+	int one = 1;
 
     name.sin_family = AF_INET;
     name.sin_port   = htons(portNumber);
@@ -857,6 +858,7 @@
     else
         name.sin_addr.s_addr = INADDR_ANY;
 
+	setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(int));
     rc = bind(fd, (struct sockaddr *)&name, sizeof(name));
 
     if (rc == -1)

Modified: freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_win.c
==============================================================================
--- freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_win.c	(original)
+++ freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_win.c	Thu Oct  2 14:50:09 2008
@@ -838,6 +838,7 @@
     
     struct sockaddr_in name;
     int rc;
+	int one = 1;
 
     ZeroMemory(&name, sizeof(name));
     name.sin_family = AF_INET;
@@ -845,6 +846,7 @@
     if (addrP)
         name.sin_addr = *addrP;
 
+	setsockopt(winsock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(int));
     rc = bind(winsock, (struct sockaddr *)&name, sizeof(name));
 
     if (rc != 0) {

Modified: freeswitch/trunk/src/mod/formats/mod_shout/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_shout/Makefile	(original)
+++ freeswitch/trunk/src/mod/formats/mod_shout/Makefile	Thu Oct  2 14:50:09 2008
@@ -11,7 +11,7 @@
 
 LAMELA=$(LAME_DIR)/libmp3lame/libmp3lame.la
 SHOUTLA=$(SHOUT_DIR)/src/libshout.la
-MPG123LA=$(MPG123_DIR)/src/libmpg123/.libs/libmpg123.la
+MPG123LA=$(MPG123_DIR)/src/libmpg123/libmpg123.la
 
 LOCAL_CFLAGS=-I$(SHOUT_DIR)/include -I$(LAME_DIR)/include -I$(MPG123_DIR)/src
 LOCAL_LIBADD=$(LAMELA) $(SHOUTLA) $(MPG123LA)

Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	(original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	Thu Oct  2 14:50:09 2008
@@ -809,21 +809,19 @@
 	ServerCreate(&globals.abyssServer, "XmlRpcServer", globals.port, SWITCH_GLOBAL_dirs.htdocs_dir, logfile);
 
 	xmlrpc_server_abyss_set_handler(&env, &globals.abyssServer, "/RPC2", registryP);
-	ServerInit(&globals.abyssServer);
 
-#if 0
 	if (ServerInit(&globals.abyssServer) != TRUE) {
 		globals.running = 0;
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to start HTTP Port %d\n", globals.port);
 		return SWITCH_STATUS_TERM;
 	}
-#endif
 
 	ServerAddHandler(&globals.abyssServer, handler_hook);
 	ServerAddHandler(&globals.abyssServer, auth_hook);
 	ServerSetKeepaliveTimeout(&globals.abyssServer, 1);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting HTTP Port %d, DocRoot [%s]\n", globals.port, SWITCH_GLOBAL_dirs.htdocs_dir);
 	ServerRun(&globals.abyssServer);
+	switch_yield(1000000);
 	globals.running = 0;
 
 	return SWITCH_STATUS_TERM;
@@ -834,9 +832,10 @@
 	//globals.abyssServer.running = 0;
 	//shutdown(globals.abyssServer.listensock, 2);
 	ServerTerminate(&globals.abyssServer);
-	while (globals.running) {
+	
+	do {
 		switch_yield(100000);
-	}
+	} while (globals.running);
 
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/trunk/src/switch.c
==============================================================================
--- freeswitch/trunk/src/switch.c	(original)
+++ freeswitch/trunk/src/switch.c	Thu Oct  2 14:50:09 2008
@@ -617,6 +617,7 @@
 	}
 
 	if (destroy_status == SWITCH_STATUS_RESTART) {
+		sleep(1);
 		ret = execv(argv[0], argv);
 	}
 



More information about the Freeswitch-svn mailing list