forked from Mirrors/freeswitch
fix xml_rpc socket shutdown
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9796 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
70e390c3e8
commit
b66e1bad4c
|
@ -191,7 +191,7 @@ void
|
|||
ServerSetMimeType(TServer * const serverP,
|
||||
MIMEType * const MIMETypeP);
|
||||
|
||||
void
|
||||
int
|
||||
ServerInit(TServer * const serverP);
|
||||
|
||||
void
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -617,6 +617,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (destroy_status == SWITCH_STATUS_RESTART) {
|
||||
sleep(1);
|
||||
ret = execv(argv[0], argv);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue