Commit d14326cc authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

brtloader.c is now 96.61% of lines and 87.13% of branches. [t:2647] Refs #2647.


git-svn-id: file:///svn/toku/tokudb@20539 c7de825b-a66e-492c-adef-691d508d4ae1
parent 543dd95c
...@@ -1483,7 +1483,6 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q ...@@ -1483,7 +1483,6 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
int r = loader_read_row_from_dbufio(bfs, i, &keys[i], &vals[i]); int r = loader_read_row_from_dbufio(bfs, i, &keys[i], &vals[i]);
BL_TRACE_QUIET(blt_read_row); BL_TRACE_QUIET(blt_read_row);
if (r==EOF) continue; // if the file is empty, don't initialize the pqueue. if (r==EOF) continue; // if the file is empty, don't initialize the pqueue.
lazy_assert(r == 0);
if (r!=0) { if (r!=0) {
result = r; result = r;
break; break;
...@@ -1547,7 +1546,6 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q ...@@ -1547,7 +1546,6 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
} }
} }
r = add_row(output_rowset, &keys[mini], &vals[mini]); r = add_row(output_rowset, &keys[mini], &vals[mini]);
lazy_assert(r == 0);
if (r!=0) { if (r!=0) {
result = r; result = r;
break; break;
......
...@@ -144,9 +144,11 @@ bad_fclose(FILE * stream) { ...@@ -144,9 +144,11 @@ bad_fclose(FILE * stream) {
static int my_malloc_event = 1; static int my_malloc_event = 1;
static int my_malloc_count = 0, my_big_malloc_count = 0; static int my_malloc_count = 0, my_big_malloc_count = 0;
static int my_realloc_count = 0, my_big_realloc_count = 0;
static void reset_my_malloc_counts(void) { static void reset_my_malloc_counts(void) {
my_malloc_count = my_big_malloc_count = 0; my_malloc_count = my_big_malloc_count = 0;
my_realloc_count = my_big_realloc_count = 0;
} }
size_t min_malloc_error_size = 0; size_t min_malloc_error_size = 0;
...@@ -174,6 +176,32 @@ static void *my_malloc(size_t n) { ...@@ -174,6 +176,32 @@ static void *my_malloc(size_t n) {
return malloc(n); return malloc(n);
} }
static int do_realloc_errors = 1;
static void *my_realloc(void *p, size_t n) {
void *caller = __builtin_return_address(0);
if (!((void*)toku_realloc <= caller && caller <= (void*)toku_free))
goto skip;
my_realloc_count++;
if (n >= min_malloc_error_size) {
my_big_realloc_count++;
if (do_realloc_errors) {
caller = __builtin_return_address(1);
if ((void*)toku_xrealloc <= caller && caller <= (void*)toku_malloc_report)
goto skip;
event_count++;
if (event_count == event_count_trigger) {
event_hit();
errno = ENOMEM;
return NULL;
}
}
}
skip:
return realloc(p, n);
}
static int qsort_compare_ints (const void *a, const void *b) { static int qsort_compare_ints (const void *a, const void *b) {
int avalue = *(int*)a; int avalue = *(int*)a;
int bvalue = *(int*)b; int bvalue = *(int*)b;
...@@ -331,6 +359,7 @@ static void test (const char *directory, BOOL is_error) { ...@@ -331,6 +359,7 @@ static void test (const char *directory, BOOL is_error) {
} }
toku_set_func_malloc(my_malloc); toku_set_func_malloc(my_malloc);
toku_set_func_realloc(my_realloc);
brtloader_set_os_fwrite(bad_fwrite); brtloader_set_os_fwrite(bad_fwrite);
toku_set_func_write(bad_write); toku_set_func_write(bad_write);
toku_set_func_pwrite(bad_pwrite); toku_set_func_pwrite(bad_pwrite);
...@@ -356,6 +385,7 @@ static void test (const char *directory, BOOL is_error) { ...@@ -356,6 +385,7 @@ static void test (const char *directory, BOOL is_error) {
} }
toku_set_func_malloc(NULL); toku_set_func_malloc(NULL);
toku_set_func_realloc(NULL);
brtloader_set_os_fwrite(NULL); brtloader_set_os_fwrite(NULL);
toku_set_func_write(NULL); toku_set_func_write(NULL);
toku_set_func_pwrite(NULL); toku_set_func_pwrite(NULL);
......
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