diff --git a/libs/xmlrpc-c/include/xmlrpc-c/abyss.h b/libs/xmlrpc-c/include/xmlrpc-c/abyss.h index 8d683092d9..274e9a957e 100644 --- a/libs/xmlrpc-c/include/xmlrpc-c/abyss.h +++ b/libs/xmlrpc-c/include/xmlrpc-c/abyss.h @@ -191,7 +191,7 @@ void ServerSetMimeType(TServer * const serverP, MIMEType * const MIMETypeP); -void +int ServerInit(TServer * const serverP); void diff --git a/libs/xmlrpc-c/lib/abyss/src/server.c b/libs/xmlrpc-c/lib/abyss/src/server.c index dc4891e116..a52c823ce6 100644 --- a/libs/xmlrpc-c/lib/abyss/src/server.c +++ b/libs/xmlrpc-c/lib/abyss/src/server.c @@ -42,12 +42,12 @@ ServerTerminate(TServer * const serverP) { srvP->terminationRequested = true; - if (srvP->chanSwitchP) + if (srvP->chanSwitchP) { ChanSwitchInterrupt(srvP->chanSwitchP); + ChanSwitchDestroy(srvP->chanSwitchP); + } } - - void ServerResetTerminate(TServer * const serverP) { @@ -651,7 +651,7 @@ createChanSwitch(struct _TServer * const srvP, -void +int ServerInit(TServer * const serverP) { /*---------------------------------------------------------------------------- Initialize a server to accept connections. @@ -700,9 +700,11 @@ ServerInit(TServer * const serverP) { } if (retError) { TraceMsg("ServerInit() failed. %s", retError); - exit(1); + return 0; xmlrpc_strfree(retError); } + + return 1; } diff --git a/libs/xmlrpc-c/lib/abyss/src/socket_unix.c b/libs/xmlrpc-c/lib/abyss/src/socket_unix.c index e554f0e54d..5d0bb0a360 100644 --- a/libs/xmlrpc-c/lib/abyss/src/socket_unix.c +++ b/libs/xmlrpc-c/lib/abyss/src/socket_unix.c @@ -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 @@ bindSocketToPort(int const fd, struct sockaddr_in name; int rc; + int one = 1; name.sin_family = AF_INET; name.sin_port = htons(portNumber); @@ -857,6 +858,7 @@ bindSocketToPort(int const fd, 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) diff --git a/libs/xmlrpc-c/lib/abyss/src/socket_win.c b/libs/xmlrpc-c/lib/abyss/src/socket_win.c index 730689584e..92b2b99cfb 100644 --- a/libs/xmlrpc-c/lib/abyss/src/socket_win.c +++ b/libs/xmlrpc-c/lib/abyss/src/socket_win.c @@ -838,6 +838,7 @@ bindSocketToPort(SOCKET const winsock, struct sockaddr_in name; int rc; + int one = 1; ZeroMemory(&name, sizeof(name)); name.sin_family = AF_INET; @@ -845,6 +846,7 @@ bindSocketToPort(SOCKET const winsock, 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) { diff --git a/src/mod/formats/mod_shout/Makefile b/src/mod/formats/mod_shout/Makefile index b270c79ec4..411f66437c 100644 --- a/src/mod/formats/mod_shout/Makefile +++ b/src/mod/formats/mod_shout/Makefile @@ -11,7 +11,7 @@ MPG123_DIR=$(switch_srcdir)/libs/$(MPG123) 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) diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c index 0c74306e04..b0f32d2f54 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c @@ -809,21 +809,19 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_xml_rpc_runtime) 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 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_rpc_shutdown) //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; } diff --git a/src/switch.c b/src/switch.c index aad686981a..c271ba9280 100644 --- a/src/switch.c +++ b/src/switch.c @@ -617,6 +617,7 @@ int main(int argc, char *argv[]) } if (destroy_status == SWITCH_STATUS_RESTART) { + sleep(1); ret = execv(argv[0], argv); }