From 5ff9abd99eab9e3583a39c06db154542a754f9f2 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sat, 9 Apr 2016 19:37:34 +1000 Subject: [PATCH] Pause timeout when in a door, so it doesn't disconnect immediatly on return --- bbs.c | 6 +++++- doors.c | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bbs.c b/bbs.c index 609f169..be554df 100644 --- a/bbs.c +++ b/bbs.c @@ -19,6 +19,7 @@ struct user_record *gUser; int gSocket; int usertimeout; +int timeoutpaused; struct fido_addr *parse_fido_addr(const char *str) { struct fido_addr *ret = (struct fido_addr *)malloc(sizeof(struct fido_addr)); @@ -89,7 +90,9 @@ void timer_handler(int signum) { } - usertimeout--; + if (timeoutpaused == 0) { + usertimeout--; + } if (usertimeout <= 0) { s_putstring(gSocket, "\r\n\r\nTimeout waiting for input..\r\n"); disconnect(gSocket); @@ -682,6 +685,7 @@ void runbbs(int socket, char *config_path) { gUser = NULL; gSocket = socket; usertimeout = 10; + timeoutpaused = 0; memset (&sa, 0, sizeof (sa)); sa.sa_handler = &timer_handler; diff --git a/doors.c b/doors.c index 87bd4bb..6c5caaa 100644 --- a/doors.c +++ b/doors.c @@ -23,6 +23,8 @@ extern int mynode; int running_door_pid = 0; int running_door = 0; +extern int timeoutpaused; + void doorchld_handler(int s) { // waitpid() might overwrite errno, so we save and restore it: @@ -136,6 +138,8 @@ void rundoor(int socket, struct user_record *user, char *cmd, int stdio) { struct winsize ws; struct sigaction sa; + timeoutpaused = 1; + if (write_door32sys(socket, user) != 0) { return; } @@ -223,6 +227,7 @@ void rundoor(int socket, struct user_record *user, char *cmd, int stdio) { sprintf(buffer, "%s %d %d", cmd, mynode, socket); system(buffer); } + timeoutpaused = 0; } int door_menu(int socket, struct user_record *user) {