From 7d9f8d0e4f9290c11dbbdb4d0446cf9459c1fd7e Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Mon, 30 Apr 2018 06:05:12 +0000 Subject: [PATCH] Bug fix: if the msgbase.lock file existed, it would cause the msgbase open (and thus fixsmb) to fail, but just before exiting, fixsmb would delete the .lock file (whoops). The msgbase.lock file means something else is rebuilding this base (e.g. smbutil) and thus we can't just go deleting the .lock file, unless we (fixmsb) was the one that created it. --- src/sbbs3/fixsmb.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sbbs3/fixsmb.c b/src/sbbs3/fixsmb.c index 6b9e99c4f1..7e42465694 100644 --- a/src/sbbs3/fixsmb.c +++ b/src/sbbs3/fixsmb.c @@ -36,6 +36,7 @@ #include <stdio.h> #include <stdlib.h> /* atoi, qsort */ +#include <stdbool.h> #include <string.h> /* strnicmp */ #include <ctype.h> /* toupper */ @@ -92,11 +93,15 @@ void sort_index(smb_t* smb) printf("\n"); } +bool we_locked_the_base = false; + void unlock_msgbase(void) { int i; - if(smb_islocked(&smb) && (i=smb_unlock(&smb))!=0) + if(we_locked_the_base && smb_islocked(&smb) && (i=smb_unlock(&smb))!=0) printf("smb_unlock returned %d: %s\n",i,smb.last_error); + else + we_locked_the_base = false; } int fixsmb(char* sub) @@ -108,7 +113,7 @@ int fixsmb(char* sub) ulong l,length,size,n; smbmsg_t msg; uint32_t* numbers = NULL; - uint32_t total = 0; + long total = 0; BOOL dupe_msgnum; uint32_t highest = 0; @@ -137,6 +142,7 @@ int fixsmb(char* sub) printf("smb_lock returned %d: %s\n",i,smb.last_error); exit(1); } + we_locked_the_base = true; if((i=smb_locksmbhdr(&smb))!=0) { smb_close(&smb); -- GitLab