Commit 209c164d authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

refs[t:2591] mutex destroy called on an uninitalized mutex

git-svn-id: file:///svn/toku/tokudb@20557 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0bcd43b8
...@@ -156,6 +156,7 @@ struct brtloader_s { ...@@ -156,6 +156,7 @@ struct brtloader_s {
BOOL *fractal_threads_live; // an array of bools indicating that fractal_threads[i] is a live thread. (There is no NULL for a pthread_t, so we have to maintain this separately). BOOL *fractal_threads_live; // an array of bools indicating that fractal_threads[i] is a live thread. (There is no NULL for a pthread_t, so we have to maintain this separately).
toku_pthread_mutex_t mutex; toku_pthread_mutex_t mutex;
BOOL mutex_init;
}; };
// Set the number of rows in the loader. Used for test. // Set the number of rows in the loader. Used for test.
......
...@@ -121,18 +121,16 @@ static void cleanup_big_buffer(struct file_info *file) { ...@@ -121,18 +121,16 @@ static void cleanup_big_buffer(struct file_info *file) {
} }
int brtloader_init_file_infos (struct file_infos *fi) { int brtloader_init_file_infos (struct file_infos *fi) {
int result = 0;
int r = toku_pthread_mutex_init(&fi->lock, NULL); resource_assert(r == 0); int r = toku_pthread_mutex_init(&fi->lock, NULL); resource_assert(r == 0);
fi->n_files = 0; fi->n_files = 0;
fi->n_files_limit = 1; fi->n_files_limit = 1;
fi->n_files_open = 0; fi->n_files_open = 0;
fi->n_files_extant = 0; fi->n_files_extant = 0;
MALLOC_N(fi->n_files_limit, fi->file_infos); MALLOC_N(fi->n_files_limit, fi->file_infos);
if (fi->file_infos) return 0; if (fi->file_infos == NULL)
else { result = errno;
int result = errno;
toku_pthread_mutex_destroy(&fi->lock); // lazy no error check and maybe done elsewhere
return result; return result;
}
} }
void brtloader_fi_destroy (struct file_infos *fi, BOOL is_error) void brtloader_fi_destroy (struct file_infos *fi, BOOL is_error)
...@@ -292,6 +290,7 @@ int brtloader_open_temp_file (BRTLOADER bl, FIDX *file_idx) ...@@ -292,6 +290,7 @@ int brtloader_open_temp_file (BRTLOADER bl, FIDX *file_idx)
} }
void toku_brtloader_internal_destroy (BRTLOADER bl, BOOL is_error) { void toku_brtloader_internal_destroy (BRTLOADER bl, BOOL is_error) {
assert(bl->mutex_init);
int r = toku_pthread_mutex_destroy(&bl->mutex); resource_assert(r == 0); int r = toku_pthread_mutex_destroy(&bl->mutex); resource_assert(r == 0);
// These frees rely on the fact that if you free a NULL pointer then nothing bad happens. // These frees rely on the fact that if you free a NULL pointer then nothing bad happens.
toku_free(bl->dbs); toku_free(bl->dbs);
...@@ -460,6 +459,7 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp, ...@@ -460,6 +459,7 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp,
{ {
int r = toku_pthread_mutex_init(&bl->mutex, NULL); int r = toku_pthread_mutex_init(&bl->mutex, NULL);
if (r != 0) { toku_brtloader_internal_destroy(bl, TRUE); return r; } if (r != 0) { toku_brtloader_internal_destroy(bl, TRUE); return r; }
bl->mutex_init = TRUE;
} }
*blp = bl; *blp = bl;
......
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