Commit 09ba3f2a authored by Dave Wells's avatar Dave Wells Committed by Yoni Fogel

address and close #2521 [t:2521]

git-svn-id: file:///svn/toku/tokudb@19894 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7525674c
......@@ -13,28 +13,17 @@ static int delete_logfile(TOKULOGGER logger, long long index);
static void grab_output(TOKULOGGER logger, LSN *fsynced_lsn);
static void release_output(TOKULOGGER logger, LSN fsynced_lsn);
// added for #2424
static BOOL is_a_logfile(char *name) {
int r=0;
long long num = 0;
int len = strlen(name);
char num_str[128];
if ( len < 11 ) goto not_logfile;
// check 'log'
r = strncmp(&name[0], "log", 3);
if (r!=0) goto not_logfile;
// check number
r = snprintf(&num_str[0], len-11, "%s", &name[3]);
r = sscanf(num_str, "%lld", &num);
if (r!=1) goto not_logfile;
// check '.tokulog'
r = strncmp(&name[len-8], ".tokulog", 8);
if (r!=0) goto not_logfile;
// added for #2424, improved for #2521
static BOOL is_a_logfile (const char *name, long long *number_result) {
unsigned long long result;
int n;
int r = sscanf(name, "log%llu.tokulog%n", &result, &n);
if (r!=1 || name[n]!=0) return FALSE;
*number_result = result;
return TRUE;
not_logfile:
return FALSE;
}
int toku_logger_create (TOKULOGGER *resultp) {
int r;
TAGMALLOC(TOKULOGGER, result);
......@@ -526,12 +515,10 @@ int toku_logger_find_next_unused_log_file(const char *directory, long long *resu
if (d==0) return errno;
while ((de=readdir(d))) {
if (de==0) return errno;
long long thisl;
int r = 0;
if ( is_a_logfile(de->d_name) ) { // #2424
r = sscanf(de->d_name, "log%lld.tokulog", &thisl);
long long thisl;
if ( is_a_logfile(de->d_name, &thisl) ) {
if ((long long)thisl > maxf) maxf = thisl;
}
if (r==1 && thisl>maxf) maxf=thisl;
}
*result=maxf+1;
int r = closedir(d);
......@@ -562,9 +549,7 @@ int toku_logger_find_logfiles (const char *directory, char ***resultp, int *n_lo
int dirnamelen = strlen(directory);
while ((de=readdir(d))) {
long long thisl;
if ( !(is_a_logfile(de->d_name)) ) continue; //#2424: Skip over files that don't match the exact logfile template
int r = sscanf(de->d_name, "log%lld.tokulog", &thisl);
if (r!=1) continue; // Skip over non-log files.
if ( !(is_a_logfile(de->d_name, &thisl)) ) continue; //#2424: Skip over files that don't match the exact logfile template
if (n_results+1>=result_limit) {
result_limit*=2;
result = toku_realloc(result, result_limit*sizeof(*result));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment