Skip to content
Snippets Groups Projects
Commit eb9a5b0e authored by rswindell's avatar rswindell
Browse files

Fix 2 bugs reported/root-caused by Deuce regarding corrupted/unpackable

bundles:
1. If the unpackable bundle file was more then 48 hours old, it would not try
to rename it - the file date/time comparison logic was backwards and was trying
to rename the file only if it was *less* than 48 hours old (and could in
theory still be in transit).
2. If the unpackable bundle file was more than 48 hours old, SBBSecho would
continuously and indefinitely try to unpack it consuming CPU cycles and
generating log output. Forever.
parent 5cada0c5
No related branches found
No related tags found
No related merge requests found
...@@ -1824,10 +1824,13 @@ BOOL unpack_bundle(void) ...@@ -1824,10 +1824,13 @@ BOOL unpack_bundle(void)
} }
if(gi<g.gl_pathc) { if(gi<g.gl_pathc) {
SAFECOPY(fname,g.gl_pathv[gi]); SAFECOPY(fname,g.gl_pathv[gi]);
gi++;
lprintf(LOG_DEBUG,"Unpacking bundle: %s",fname); lprintf(LOG_DEBUG,"Unpacking bundle: %s",fname);
if(unpack(fname)) { /* failure */ if(unpack(fname)) { /* failure */
lprintf(LOG_ERR,"!Unpack failure"); lprintf(LOG_ERR,"!Unpack failure");
if(fdate(fname)+(48L*60L*60L)>time(NULL)) { if(fdate(fname)+(48L*60L*60L)<time(NULL)) {
/* If bundle file older than 48 hours, give up and rename
to "*.?_?" or (if it exists) "*.?-?" */
SAFECOPY(str,fname); SAFECOPY(str,fname);
str[strlen(str)-2]='_'; str[strlen(str)-2]='_';
if(fexistcase(str)) if(fexistcase(str))
...@@ -1837,15 +1840,13 @@ BOOL unpack_bundle(void) ...@@ -1837,15 +1840,13 @@ BOOL unpack_bundle(void)
if(rename(fname,str)) if(rename(fname,str))
lprintf(LOG_ERR,"ERROR line %d renaming %s to %s" lprintf(LOG_ERR,"ERROR line %d renaming %s to %s"
,__LINE__,fname,str); ,__LINE__,fname,str);
} }
} continue;
else {
lprintf(LOG_DEBUG,"Deleting bundle: %s", fname);
if(delfile(fname)) /* successful, so delete bundle */
lprintf(LOG_ERR,"ERROR line %d removing %s %s",__LINE__,fname
,strerror(errno));
} }
gi++; lprintf(LOG_DEBUG,"Deleting bundle: %s", fname);
if(delfile(fname)) /* successful, so delete bundle */
lprintf(LOG_ERR,"ERROR line %d removing %s %s",__LINE__,fname
,strerror(errno));
return(TRUE); return(TRUE);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment