FINALLY nodeinuse deleted when disconnecting

This commit is contained in:
Andrew Pamment 2016-08-07 16:15:41 +10:00
parent 051a3a4071
commit 77edc6ee0a
2 changed files with 5 additions and 5 deletions

1
bbs.c
View File

@ -31,6 +31,7 @@ void sigterm_handler2(int s)
if (mynode != 0) { if (mynode != 0) {
disconnect("Terminated."); disconnect("Terminated.");
} }
dolog("Terminated...");
exit(0); exit(0);
} }

9
main.c
View File

@ -30,6 +30,7 @@ extern struct bbs_config conf;
extern struct user_record *gUser; extern struct user_record *gUser;
int ssh_pid = -1; int ssh_pid = -1;
int bbs_pid = 0;
void sigterm_handler(int s) void sigterm_handler(int s)
{ {
@ -449,7 +450,8 @@ static void ssh_chan_close(ssh_session session, ssh_channel channel, void *userd
int fd = *(int*)userdata; int fd = *(int*)userdata;
(void)session; (void)session;
(void)channel; (void)channel;
kill(bbs_pid, SIGTERM);
sleep(10);
close(fd); close(fd);
} }
@ -468,7 +470,6 @@ void serverssh(int port) {
int shell = 0; int shell = 0;
int fd; int fd;
ssh_channel chan = 0; ssh_channel chan = 0;
int bbs_pid;
char *ip; char *ip;
ssh_event event; ssh_event event;
short events; short events;
@ -593,8 +594,6 @@ void serverssh(int port) {
ssh_event_dopoll(event, 1000); ssh_event_dopoll(event, 1000);
} while(!ssh_channel_is_closed(chan)); } while(!ssh_channel_is_closed(chan));
ssh_event_remove_fd(event, fd); ssh_event_remove_fd(event, fd);
ssh_event_remove_session(event, p_ssh_session); ssh_event_remove_session(event, p_ssh_session);
@ -603,7 +602,7 @@ void serverssh(int port) {
} }
ssh_disconnect(p_ssh_session); ssh_disconnect(p_ssh_session);
ssh_finalize(); ssh_finalize();
kill(bbs_pid, SIGTERM);
exit(0); exit(0);
} else if (pid > 0) { } else if (pid > 0) {