From 1febff88c3c1c2711b75c5016bc02ee5097bc332 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 14 Nov 2001 19:50:27 +0000 Subject: [PATCH] Added lock timeout to mbmail, increased flag logging --- ChangeLog | 5 +++++ lib/msgflags.c | 7 +++---- mbfido/mbfido.c | 29 ++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3b2bb7b..2eb33484 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4299,3 +4299,8 @@ v0.33.19 26-Oct-2001 import: Removed users import, could not work anymore. + mbfido: + When running in mbmail mode, it will try to get the lock on + the program for 10 minutes before aborting. + + diff --git a/lib/msgflags.c b/lib/msgflags.c index 01b047fb..786a6f99 100644 --- a/lib/msgflags.c +++ b/lib/msgflags.c @@ -1,8 +1,7 @@ /***************************************************************************** * - * File ..................: msgflags.c + * $Id$ * Purpose ...............: MBSE BBS Mail Gate - * Last modification date : 06-Jun-2001 * ***************************************************************************** * Copyright (C) 1997-2001 @@ -128,7 +127,7 @@ int flag_on(char *flag, char *flags) char *p,*tok; int up=0; - Syslog('M', "checking flag \"%s\" in string \"%s\"",MBSE_SS(flag),MBSE_SS(flags)); + Syslog('m', "checking flag \"%s\" in string \"%s\"",MBSE_SS(flag),MBSE_SS(flags)); if (flags == NULL) return 0; p=xstrcpy(flags); @@ -137,7 +136,7 @@ int flag_on(char *flag, char *flags) up = 1; } free(p); - Syslog('M', "flag%s present",up?"":" not"); + Syslog('m', "flag%s present",up?"":" not"); return up; } diff --git a/mbfido/mbfido.c b/mbfido/mbfido.c index 96acb0e2..05899e4b 100644 --- a/mbfido/mbfido.c +++ b/mbfido/mbfido.c @@ -412,8 +412,35 @@ int main(int argc, char **argv) if (!diskfree(CFG.freespace)) die(101); - if (lockunpack()) + if (do_mail) { + /* + * Try to get a lock for a long time, another mbfido may be legally + * running since mbmail is started by the MTA instead of by mbtask. + * The timeout is 10 minutes. If mbmail times out, the MTA will + * bounce the message. What happens during the time we wait is + * unknown, will the MTA be patient enough? + */ + i = 30; + while (TRUE) { + if (lockunpack() == 0) + break; + i--; + if (! i) { + WriteError("Lock timeout, aborting"); + die(101); + } + sleep(20); + Nopper(); + } + } else { + /* + * Started under control of mbtask, that means if there is a lock then + * there is something wrong; abort. + */ + if (lockunpack()) die(101); + } + if (initnl()) die(101); if (!do_mail && !do_uucp)