From 1c7d22ed1a5084265e884e8a41284a7caf047de6 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 19 May 2002 11:24:01 +0000 Subject: [PATCH] Made mbtask port check more relaxed --- ChangeLog | 4 +++- mbtask/ports.c | 22 ++++++++++++++++------ mbtask/ports.h | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3043199b..e9032d53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4811,7 +4811,9 @@ v0.33.20 10-Feb-2002 Removed some debug logging. Creates the semafore is_inet when the internet connections is available, and removes it when it is down. - Added test for ISDN/modem lines in use. + Added test for ISDN/modem lines in use. If a line status + change lasted 5 seconds or longer, the oubound will be + rescanned. Lots of code cleanup. No setup setting anymore for maximum POTS and ISDN lines, this is now automatic. diff --git a/mbtask/ports.c b/mbtask/ports.c index 8c57d0fe..21feceea 100644 --- a/mbtask/ports.c +++ b/mbtask/ports.c @@ -183,11 +183,12 @@ void check_ports(void) if ((lf = fopen(lckname, "r")) == NULL) { if (tpl->locked) { tpl->locked = 0; - tasklog('+', "Port %s is now free", tpl->tty); - /* - * Good, set master rescan flag - */ - changed = TRUE; + tasklog('+', "Port %s is now free after %d seconds", tpl->tty, tpl->locktime); + if (tpl->locktime > 4) + /* + * Good, set master rescan flag if longer then 4 seconds locked. + */ + changed = TRUE; } } else { fscanf(lf, "%d", &tmppid); @@ -200,8 +201,17 @@ void check_ports(void) } else { if (!tpl->locked) { tpl->locked = rempid; + tpl->locktime = 0; tasklog('+', "Port %s locked, pid %d", tpl->tty, rempid); - changed = TRUE; + } else { + /* + * Count locktime + */ + tpl->locktime++; + if (tpl->locktime == 5) { + changed = TRUE; + tasklog('+', "Port %s locked for 5 seconds, forcing scan", tpl->tty); + } } } } diff --git a/mbtask/ports.h b/mbtask/ports.h index 84b62233..1bb5ed8c 100644 --- a/mbtask/ports.h +++ b/mbtask/ports.h @@ -14,6 +14,7 @@ typedef struct _pp_list { unsigned long mflags; /* Analogue modem flags */ unsigned long dflags; /* ISDN flags */ int locked; /* If port is locked */ + long locktime; /* Time it is locked */ } pp_list;