Add shutdown tracing for nwserv, nwbind and ncpserv
This commit is contained in:
@@ -428,6 +428,7 @@ static void ncp_response(int type, int sequence,
|
||||
|
||||
static void close_all(void)
|
||||
{
|
||||
XDPRINTF((1,0, "close_all: entering ncpserv shutdown"));
|
||||
int k=0;
|
||||
while (k++ < count_connections) clear_connection(k);
|
||||
kill_connections();
|
||||
@@ -437,7 +438,7 @@ static void close_all(void)
|
||||
if (ncp_fd > -1) {
|
||||
t_unbind(ncp_fd);
|
||||
t_close(ncp_fd);
|
||||
XDPRINTF((2,0, "LEAVE ncpserv"));
|
||||
XDPRINTF((1,0, "LEAVE ncpserv"));
|
||||
ncp_fd = -1;
|
||||
if (ipx_out_fd > -1) {
|
||||
t_unbind(ipx_out_fd);
|
||||
@@ -450,6 +451,7 @@ static void close_all(void)
|
||||
static int server_is_down=0;
|
||||
static void sig_quit(int isig)
|
||||
{
|
||||
XDPRINTF((1, 0, "sig_quit: ncpserv got signal=%d", isig));
|
||||
server_is_down++;
|
||||
}
|
||||
|
||||
@@ -514,8 +516,10 @@ static int handle_ctrl(void)
|
||||
|
||||
case 0xffff : /* server down */
|
||||
data_len = xread(ipxd, &offs, (uint8*)&conn, sizeof(int));
|
||||
if (sizeof(int) == data_len && conn == what)
|
||||
if (sizeof(int) == data_len && conn == what) {
|
||||
XDPRINTF((1, 0, "handle_ctrl: ncpserv got CTRL 0xffff, conn=0x%x", conn));
|
||||
server_goes_down++;
|
||||
}
|
||||
break;
|
||||
|
||||
default : break;
|
||||
|
||||
11
src/nwbind.c
11
src/nwbind.c
@@ -2067,8 +2067,10 @@ static void handle_ctrl()
|
||||
|
||||
case 0xffff : /* server down */
|
||||
data_len = xread(&ipxd, &offs, (char*)&conn, sizeof(int));
|
||||
if (sizeof(int) == data_len && conn == what)
|
||||
if (sizeof(int) == data_len && conn == what) {
|
||||
XDPRINTF((1, 0, "handle_ctrl: nwbind got CTRL 0xffff, conn=0x%x", conn));
|
||||
sent_down_message();
|
||||
}
|
||||
break;
|
||||
default : break;
|
||||
} /* switch */
|
||||
@@ -2081,6 +2083,7 @@ static void handle_ctrl()
|
||||
static int got_sig=0;
|
||||
static void sig_handler(int isig)
|
||||
{
|
||||
XDPRINTF((1, 0, "sig_handler: nwbind got signal=%d", isig));
|
||||
got_sig=isig;
|
||||
signal(isig, sig_handler);
|
||||
}
|
||||
@@ -2227,11 +2230,15 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (got_sig == SIGHUP) {
|
||||
/* here I update some Bindery stuff from nwserv.conf */
|
||||
XDPRINTF((1, 0, "main: nwbind handling SIGHUP"));
|
||||
reinit_nwbind();
|
||||
got_sig = 0;
|
||||
} else if (got_sig == SIGUSR2) {
|
||||
XDPRINTF((1, 0, "main: nwbind handling SIGUSR2"));
|
||||
handle_usr2(); /* mst:25-Apr-00 */
|
||||
got_sig = 0;
|
||||
} else if (got_sig == SIGQUIT) {
|
||||
XDPRINTF((1, 0, "main: nwbind leaving main loop on SIGQUIT"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2251,6 +2258,6 @@ int main(int argc, char *argv[])
|
||||
internal_act=1;
|
||||
nw_exit_dbm();
|
||||
xfree(connections);
|
||||
XDPRINTF((2,0, "LEAVE nwbind"));
|
||||
XDPRINTF((1,0, "LEAVE nwbind"));
|
||||
return(0);
|
||||
}
|
||||
|
||||
50
src/nwserv.c
50
src/nwserv.c
@@ -24,6 +24,8 @@
|
||||
#ifdef LINUX
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
uint32 internal_net = 0x0L; /* NETWORKNUMMER INTERN (SERVER) */
|
||||
int no_internal = 0; /* no use of internal net */
|
||||
@@ -1088,24 +1090,61 @@ static void close_all(void)
|
||||
|
||||
if (pid_ncpserv > 0) {
|
||||
int status;
|
||||
int tries = 20;
|
||||
if (fd_ncpserv_in > -1) {
|
||||
close(fd_ncpserv_in);
|
||||
fd_ncpserv_in = -1;
|
||||
}
|
||||
XDPRINTF((1, 0, "close_all: sending SIGQUIT to ncpserv pid=%d", pid_ncpserv));
|
||||
kill(pid_ncpserv, SIGQUIT); /* terminate ncpserv */
|
||||
waitpid(pid_ncpserv, &status, 0);
|
||||
kill(pid_ncpserv, SIGKILL); /* kill ncpserv */
|
||||
while (tries-- > 0) {
|
||||
pid_t r = waitpid(pid_ncpserv, &status, WNOHANG);
|
||||
if (r == pid_ncpserv) {
|
||||
XDPRINTF((1, 0, "close_all: ncpserv pid=%d exited after SIGQUIT", pid_ncpserv));
|
||||
pid_ncpserv = -1;
|
||||
break;
|
||||
}
|
||||
if (r < 0) {
|
||||
XDPRINTF((1, 0, "close_all: waitpid for ncpserv pid=%d failed", pid_ncpserv));
|
||||
pid_ncpserv = -1;
|
||||
break;
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
if (pid_ncpserv > 0) {
|
||||
XDPRINTF((1, 0, "close_all: ncpserv pid=%d did not exit, sending SIGKILL", pid_ncpserv));
|
||||
kill(pid_ncpserv, SIGKILL); /* kill ncpserv */
|
||||
waitpid(pid_ncpserv, &status, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (pid_nwbind > 0) {
|
||||
int status;
|
||||
int tries = 20;
|
||||
if (fd_nwbind_in > -1) {
|
||||
close(fd_nwbind_in);
|
||||
fd_nwbind_in = -1;
|
||||
}
|
||||
kill(pid_nwbind, SIGQUIT); /* terminate nwbind */
|
||||
waitpid(pid_nwbind, &status, 0);
|
||||
kill(pid_nwbind, SIGKILL); /* kill nwbind */
|
||||
while (tries-- > 0) {
|
||||
pid_t r = waitpid(pid_nwbind, &status, WNOHANG);
|
||||
if (r == pid_nwbind) {
|
||||
XDPRINTF((1, 0, "close_all: nwbind pid=%d exited after SIGQUIT", pid_nwbind));
|
||||
pid_nwbind = -1;
|
||||
break;
|
||||
}
|
||||
if (r < 0) {
|
||||
XDPRINTF((1, 0, "close_all: waitpid for nwbind pid=%d failed", pid_nwbind));
|
||||
pid_nwbind = -1;
|
||||
break;
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
if (pid_nwbind > 0) {
|
||||
XDPRINTF((1, 0, "close_all: nwbind pid=%d did not exit, sending SIGKILL", pid_nwbind));
|
||||
kill(pid_nwbind, SIGKILL); /* kill nwbind */
|
||||
waitpid(pid_nwbind, &status, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LINUX
|
||||
@@ -1142,6 +1181,7 @@ static void down_server(void)
|
||||
if (!server_down_stamp) {
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
XDPRINTF((1, 0, "down_server: sending CTRL 0xffff to ncpserv and nwbind"));
|
||||
write_to_ncpserv(0xffff, 0, NULL, 0);
|
||||
write_to_nwbind( 0xffff, 0, NULL, 0);
|
||||
fprintf(stderr, "\007");
|
||||
@@ -1170,7 +1210,7 @@ static void sig_quit(int rsig)
|
||||
{
|
||||
signal(rsig, SIG_IGN);
|
||||
signal(SIGHUP, SIG_IGN); /* don't want it anymore */
|
||||
XDPRINTF((2, 0, "Got Signal=%d", rsig));
|
||||
XDPRINTF((1, 0, "sig_quit: nwserv got signal=%d", rsig));
|
||||
fl_get_int|=2;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user