From 1b71865b7d288d1550f6b594bfc0af84d6f884e4 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Wed, 20 Apr 2011 21:50:56 +0000 Subject: [PATCH] minor log fixes. add stasis_log_chunk_name flag. --- src/stasis/flags.c | 10 ++++++++-- src/stasis/logger/filePool.c | 10 ++++------ stasis/flags.h | 1 + stasis/logger/filePool.h | 3 +++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/stasis/flags.c b/src/stasis/flags.c index 4780473..a2d2aad 100644 --- a/src/stasis/flags.c +++ b/src/stasis/flags.c @@ -174,12 +174,18 @@ int stasis_log_softcommit = STASIS_LOG_SOFTCOMMIT; int stasis_log_softcommit = 0; #endif -#ifdef STASIS_LOG_DIR -const char* stasis_log_dir_name = STASIS_LOG_DIR; +#ifdef STASIS_LOG_DIR_NAME +const char* stasis_log_dir_name = STASIS_LOG_DIR_NAME; #else const char* stasis_log_dir_name = "stasis_log"; #endif +#ifdef STASIS_LOG_CHUNK_NAME +const char* stasis_log_chunk_name = STASIS_LOG_CHUNK_NAME; +#else +const char* stasis_log_chunk_name = "log-chunk-"; +#endif + #ifdef STASIS_LOG_FILE_POOL_LSN_CHARS #error 2 ^ 64 is 20 chars in base ten, so there is no reason to redefine STASIS_LOG_FILE_POOL_LSN_CHARS #endif //STASIS_LOG_DIR_LSN_CHARS diff --git a/src/stasis/logger/filePool.c b/src/stasis/logger/filePool.c index e4dbd47..c789470 100644 --- a/src/stasis/logger/filePool.c +++ b/src/stasis/logger/filePool.c @@ -92,8 +92,8 @@ enum file_type stasis_log_file_pool_file_type(const struct dirent* file, lsn_t * ||DT_UNKNOWN == file->d_type)) { return UNKNOWN; } - off_t base_len = strlen(stasis_log_dir_name); - if(strncmp(name, stasis_log_dir_name, base_len)) { + off_t base_len = strlen(stasis_log_chunk_name); + if(strncmp(name, stasis_log_chunk_name, base_len)) { return UNKNOWN; } name+=base_len; @@ -127,13 +127,11 @@ int stasis_log_file_pool_file_filter(const struct dirent* file) { */ char * stasis_log_file_pool_build_filename(stasis_log_file_pool_state * fp, lsn_t start_lsn) { - int name_len = strlen(stasis_log_dir_name); + int name_len = strlen(stasis_log_chunk_name); char * first = malloc(name_len + stasis_log_file_pool_lsn_chars + 1); - strcpy(first, stasis_log_dir_name); + strcpy(first, stasis_log_chunk_name); sprintf(first+name_len, "%020lld", start_lsn); printf("Name is %s\n", first); - char * full_name = malloc(strlen(fp->dirname) + 1 + strlen(first) + 1); - full_name[0] = 0; return first; } diff --git a/stasis/flags.h b/stasis/flags.h index 2f66335..579a608 100644 --- a/stasis/flags.h +++ b/stasis/flags.h @@ -158,6 +158,7 @@ extern char * stasis_store_file_2_name; extern int stasis_buffer_manager_hash_prefetch_count; extern const char * stasis_log_dir_name; +extern const char * stasis_log_chunk_name; /** Maximum number of log chunks that will be created by file pool. This number is treated as a hint. diff --git a/stasis/logger/filePool.h b/stasis/logger/filePool.h index bb8ce99..f72aefd 100644 --- a/stasis/logger/filePool.h +++ b/stasis/logger/filePool.h @@ -4,6 +4,9 @@ #include #include +BEGIN_C_DECLS + stasis_log_t* stasis_log_file_pool_open(const char* dirname, int filemode, int fileperm); +END_C_DECLS #endif