From 509b9bbc2bfd2194ff08b30d20dd0ca847bc0413 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 15 Feb 2002 19:29:33 +0000 Subject: [PATCH] Second attempt unzip mail archives patch --- ChangeLog | 3 +++ mbfido/ulock.c | 66 +++++++++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 618d1e2f..f6f8a021 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4610,6 +4610,9 @@ v0.33.20 10-Feb-2002 from a uplink which has a echomail taglist in one of the mailgroups defined. The area is created with the defaults from the mailgroup. + If mbfido fails to unzip a incoming mailarchive, a second + attempt is done after a sync() and one second delay. This + seems to be a kernel flush problem. mball: Will not crash anymore when it needs more then 10 minutes to diff --git a/mbfido/ulock.c b/mbfido/ulock.c index c047874b..82d3d29a 100644 --- a/mbfido/ulock.c +++ b/mbfido/ulock.c @@ -139,43 +139,49 @@ int checkspace(char *dir, char *fn, int factor) */ int unpack(char *fn) { - char newname[16]; - char *cmd = NULL, *unarc; - int rc = 0, ld; + char newname[16]; + char *cmd = NULL, *unarc; + int rc = 0, ld; - if (!do_quiet) { - colour(11, 0); - printf("Unpacking file %s\n", fn); - } + if (!do_quiet) { + colour(11, 0); + printf("Unpacking file %s\n", fn); + } - if ((unarc = unpacker(fn)) == NULL) - return 1; + if ((unarc = unpacker(fn)) == NULL) + return 1; - if (!getarchiver(unarc)) - return 1; + if (!getarchiver(unarc)) + return 1; - cmd = xstrcpy(archiver.munarc); + cmd = xstrcpy(archiver.munarc); - if ((cmd == NULL) || (cmd == "")) - return -1; - - if ((ld = f_lock(fn)) == -1) { - free(cmd); - return 1; - } - - rc = execute(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null"); - if (rc == 0) - unlink(fn); - else { - strncpy(newname,fn,sizeof(newname)-1); - strcpy(newname+8,".bad"); - rename(fn,newname); - } + if ((cmd == NULL) || (cmd == "")) + return -1; + if ((ld = f_lock(fn)) == -1) { free(cmd); - funlock(ld); - return rc; + return 1; + } + + if ((rc = execute(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) { + unlink(fn); + } else { + sync(); + sleep(1); + Syslog('!', "Warning: unpack %s failed, trying again after sync()"); + if ((rc = execute(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) { + unlink(fn); + } else { + strncpy(newname,fn,sizeof(newname)-1); + strcpy(newname+8,".bad"); + rename(fn,newname); + } + } + + free(cmd); + funlock(ld); + return rc; }