Skip to content
Snippets Groups Projects
Commit b99de982 authored by rswindell's avatar rswindell
Browse files

services_terminate() and recycling services no longer closes sockets for

static services (such services are responsible for closing their own server
socket) - this allows for more graceful shutdown of ircd.js.
No longer runs static services if bind failed for that service's server socket.
parent 238752ed
No related branches found
No related tags found
No related merge requests found
......@@ -1390,6 +1390,8 @@ void DLLCALL services_terminate(void)
for(i=0;i<services;i++) {
if(service[i].socket==INVALID_SOCKET)
continue;
if(service[i].options&SERVICE_OPT_STATIC)
continue;
close_socket(service[i].socket);
service[i].socket=INVALID_SOCKET;
}
......@@ -1551,7 +1553,6 @@ void DLLCALL services_thread(void* arg)
char host_ip[32];
char compiler[32];
char str[128];
char cmd[128];
SOCKADDR_IN addr;
SOCKADDR_IN client_addr;
socklen_t client_addr_len;
......@@ -1763,10 +1764,10 @@ void DLLCALL services_thread(void* arg)
for(i=0;i<(int)services;i++) {
if(!(service[i].options&SERVICE_OPT_STATIC))
continue;
if(service[i].socket==INVALID_SOCKET) /* bind failure? */
continue;
/* start thread here */
SAFECOPY(cmd,service[i].cmd);
strlwr(cmd);
if(service[i].options&SERVICE_OPT_NATIVE) /* Native */
_beginthread(native_static_service_thread, 0, &service[i]);
else /* JavaScript */
......@@ -2016,8 +2017,6 @@ void DLLCALL services_thread(void* arg)
udp_buf = NULL;
SAFECOPY(cmd,service[i].cmd);
strlwr(cmd);
if(service[i].options&SERVICE_OPT_NATIVE) /* Native */
_beginthread(native_service_thread, 0, client);
else /* JavaScript */
......@@ -2031,8 +2030,11 @@ void DLLCALL services_thread(void* arg)
lprintf("0000 Closing service sockets");
for(i=0;i<(int)services;i++) {
service[i].terminated=TRUE;
if(service[i].socket!=INVALID_SOCKET)
close_socket(service[i].socket);
if(service[i].socket==INVALID_SOCKET)
continue;
if(service[i].options&SERVICE_OPT_STATIC)
continue;
close_socket(service[i].socket);
service[i].socket=INVALID_SOCKET;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment