Commit bc70e073 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Closes [t:2624] Added toku_os_close() which retries on EINTR. Closes [t:2621]...

Closes [t:2624] Added toku_os_close() which retries on EINTR.  Closes [t:2621] Added toku_os_open(), toku_os_fopen(), toku_os_fdopen(), toku_os_fclose() and related override hooks  db_env_set_func_open(), db_env_set_func_fopen(), db_env_set_func_fdopen(), db_env_set_func_fclose(). Modified test program loader-cleanup-test to use new hooks to inject synthetic errors.  Marked some error cases in brtloader.c. with ###.

git-svn-id: file:///svn/toku/tokudb@20364 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3444202c
...@@ -484,11 +484,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default"))) ...@@ -484,11 +484,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")))
int toku_close_trace_file (void) __attribute__((__visibility__("default"))); int toku_close_trace_file (void) __attribute__((__visibility__("default")));
int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default"))); int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_fdopen (FILE* (*)(int, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_fopen (FILE* (*)(const char *, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_open (int (*)(const char *, int, int)) __attribute__((__visibility__("default")));
int db_env_set_func_fclose (int (*)(FILE*)) __attribute__((__visibility__("default")));
void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default"))); void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
......
...@@ -500,11 +500,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default"))) ...@@ -500,11 +500,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")))
int toku_close_trace_file (void) __attribute__((__visibility__("default"))); int toku_close_trace_file (void) __attribute__((__visibility__("default")));
int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default"))); int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_fdopen (FILE* (*)(int, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_fopen (FILE* (*)(const char *, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_open (int (*)(const char *, int, int)) __attribute__((__visibility__("default")));
int db_env_set_func_fclose (int (*)(FILE*)) __attribute__((__visibility__("default")));
void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default"))); void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
......
...@@ -508,11 +508,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default"))) ...@@ -508,11 +508,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")))
int toku_close_trace_file (void) __attribute__((__visibility__("default"))); int toku_close_trace_file (void) __attribute__((__visibility__("default")));
int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default"))); int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_fdopen (FILE* (*)(int, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_fopen (FILE* (*)(const char *, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_open (int (*)(const char *, int, int)) __attribute__((__visibility__("default")));
int db_env_set_func_fclose (int (*)(FILE*)) __attribute__((__visibility__("default")));
void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default"))); void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
......
...@@ -508,11 +508,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default"))) ...@@ -508,11 +508,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")))
int toku_close_trace_file (void) __attribute__((__visibility__("default"))); int toku_close_trace_file (void) __attribute__((__visibility__("default")));
int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default"))); int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_fdopen (FILE* (*)(int, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_fopen (FILE* (*)(const char *, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_open (int (*)(const char *, int, int)) __attribute__((__visibility__("default")));
int db_env_set_func_fclose (int (*)(FILE*)) __attribute__((__visibility__("default")));
void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default"))); void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
......
...@@ -513,11 +513,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default"))) ...@@ -513,11 +513,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")))
int toku_close_trace_file (void) __attribute__((__visibility__("default"))); int toku_close_trace_file (void) __attribute__((__visibility__("default")));
int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default"))); int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_fdopen (FILE* (*)(int, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_fopen (FILE* (*)(const char *, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_open (int (*)(const char *, int, int)) __attribute__((__visibility__("default")));
int db_env_set_func_fclose (int (*)(FILE*)) __attribute__((__visibility__("default")));
void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default"))); void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
......
...@@ -669,11 +669,15 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__ ...@@ -669,11 +669,15 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
printf("int toku_close_trace_file (void) %s;\n", VISIBLE); printf("int toku_close_trace_file (void) %s;\n", VISIBLE);
printf("int db_env_set_func_free (void (*)(void*)) %s;\n", VISIBLE); printf("int db_env_set_func_free (void (*)(void*)) %s;\n", VISIBLE);
printf("int db_env_set_func_malloc (void *(*)(size_t)) %s;\n", VISIBLE); printf("int db_env_set_func_malloc (void *(*)(size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_realloc (void *(*)(void*, size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n", VISIBLE); printf("int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n", VISIBLE); printf("int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE); printf("int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE); printf("int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_realloc (void *(*)(void*, size_t)) %s;\n", VISIBLE); printf("int db_env_set_func_fdopen (FILE* (*)(int, const char *)) %s;\n", VISIBLE);
printf("int db_env_set_func_fopen (FILE* (*)(const char *, const char *)) %s;\n", VISIBLE);
printf("int db_env_set_func_open (int (*)(const char *, int, int)) %s;\n", VISIBLE);
printf("int db_env_set_func_fclose (int (*)(FILE*)) %s;\n", VISIBLE);
printf("void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) %s;\n", VISIBLE); printf("void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) %s;\n", VISIBLE);
printf("void db_env_set_checkpoint_callback (void (*)(void*), void*) %s;\n", VISIBLE); printf("void db_env_set_checkpoint_callback (void (*)(void*), void*) %s;\n", VISIBLE);
printf("void db_env_set_checkpoint_callback2 (void (*)(void*), void*) %s;\n", VISIBLE); printf("void db_env_set_checkpoint_callback2 (void (*)(void*), void*) %s;\n", VISIBLE);
......
...@@ -445,11 +445,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default"))) ...@@ -445,11 +445,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")))
int toku_close_trace_file (void) __attribute__((__visibility__("default"))); int toku_close_trace_file (void) __attribute__((__visibility__("default")));
int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default"))); int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_fdopen (FILE* (*)(int, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_fopen (FILE* (*)(const char *, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_open (int (*)(const char *, int, int)) __attribute__((__visibility__("default")));
int db_env_set_func_fclose (int (*)(FILE*)) __attribute__((__visibility__("default")));
void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default"))); void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
......
...@@ -445,11 +445,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default"))) ...@@ -445,11 +445,15 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")))
int toku_close_trace_file (void) __attribute__((__visibility__("default"))); int toku_close_trace_file (void) __attribute__((__visibility__("default")));
int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default"))); int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_full_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_fdopen (FILE* (*)(int, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_fopen (FILE* (*)(const char *, const char *)) __attribute__((__visibility__("default")));
int db_env_set_func_open (int (*)(const char *, int, int)) __attribute__((__visibility__("default")));
int db_env_set_func_fclose (int (*)(FILE*)) __attribute__((__visibility__("default")));
void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default"))); void db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <dirent.h> #include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
static int toku_assert_on_write_enospc = 0; static int toku_assert_on_write_enospc = 0;
static const int toku_write_enospc_sleep = 1; static const int toku_write_enospc_sleep = 1;
...@@ -98,7 +102,10 @@ static ssize_t (*t_write)(int, const void *, size_t) = 0; ...@@ -98,7 +102,10 @@ static ssize_t (*t_write)(int, const void *, size_t) = 0;
static ssize_t (*t_full_write)(int, const void *, size_t) = 0; static ssize_t (*t_full_write)(int, const void *, size_t) = 0;
static ssize_t (*t_pwrite)(int, const void *, size_t, off_t) = 0; static ssize_t (*t_pwrite)(int, const void *, size_t, off_t) = 0;
static ssize_t (*t_full_pwrite)(int, const void *, size_t, off_t) = 0; static ssize_t (*t_full_pwrite)(int, const void *, size_t, off_t) = 0;
static FILE * (*t_fdopen)(int, const char *) = 0;
static FILE * (*t_fopen)(const char *, const char *) = 0;
static int (*t_open)(const char *, int, int) = 0; // no implementation of variadic form until needed
static int (*t_fclose)(FILE *) = 0;
int int
toku_set_func_write (ssize_t (*write_fun)(int, const void *, size_t)) { toku_set_func_write (ssize_t (*write_fun)(int, const void *, size_t)) {
...@@ -112,8 +119,6 @@ toku_set_func_full_write (ssize_t (*write_fun)(int, const void *, size_t)) { ...@@ -112,8 +119,6 @@ toku_set_func_full_write (ssize_t (*write_fun)(int, const void *, size_t)) {
return 0; return 0;
} }
int int
toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, off_t)) { toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, off_t)) {
t_pwrite = pwrite_fun; t_pwrite = pwrite_fun;
...@@ -126,6 +131,32 @@ toku_set_func_full_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, off_ ...@@ -126,6 +131,32 @@ toku_set_func_full_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, off_
return 0; return 0;
} }
int
toku_set_func_fdopen(FILE * (*fdopen_fun)(int, const char *)) {
t_fdopen = fdopen_fun;
return 0;
}
int
toku_set_func_fopen(FILE * (*fopen_fun)(const char *, const char *)) {
t_fopen = fopen_fun;
return 0;
}
int
toku_set_func_open(int (*open_fun)(const char *, int, int)) {
t_open = open_fun;
return 0;
}
int
toku_set_func_fclose(int (*fclose_fun)(FILE*)) {
t_fclose = fclose_fun;
return 0;
}
void void
...@@ -214,6 +245,65 @@ toku_os_pwrite (int fd, const void *buf, size_t len, toku_off_t off) { ...@@ -214,6 +245,65 @@ toku_os_pwrite (int fd, const void *buf, size_t len, toku_off_t off) {
return result; return result;
} }
FILE *
toku_os_fdopen(int fildes, const char *mode) {
FILE * rval;
if (t_fdopen)
rval = t_fdopen(fildes, mode);
else
rval = fdopen(fildes, mode);
return rval;
}
FILE *
toku_os_fopen(const char *filename, const char *mode){
FILE * rval;
if (t_fopen)
rval = t_fopen(filename, mode);
else
rval = fopen(filename, mode);
return rval;
}
int
toku_os_open(const char *path, int oflag, int mode) {
int rval;
if (t_open)
rval = t_open(path, oflag, mode);
else
rval = open(path, oflag, mode);
return rval;
}
int
toku_os_fclose(FILE * stream) {
int rval = -1;
if (t_fclose)
rval = t_fclose(stream);
else { // if EINTR, retry until success
while (rval != 0) {
rval = fclose(stream);
if (rval && (errno != EINTR))
break;
}
}
return rval;
}
int
toku_os_close (int fd) { // if EINTR, retry until success
int r = -1;
while (r != 0) {
r = close(fd);
if (r) {
int rr = errno;
if (rr!=EINTR) printf("rr=%d (%s)\n", rr, strerror(rr));
assert(rr==EINTR);
}
}
return r;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -156,7 +156,7 @@ void brtloader_fi_destroy (struct file_infos *fi, BOOL is_error) ...@@ -156,7 +156,7 @@ void brtloader_fi_destroy (struct file_infos *fi, BOOL is_error)
for (int i=0; i<fi->n_files; i++) { for (int i=0; i<fi->n_files; i++) {
if (fi->file_infos[i].is_open) { if (fi->file_infos[i].is_open) {
invariant(is_error); invariant(is_error);
fclose(fi->file_infos[i].file); // don't check for errors, since we are in an error case. toku_os_fclose(fi->file_infos[i].file); // don't check for errors, since we are in an error case.
} }
if (fi->file_infos[i].is_extant) { if (fi->file_infos[i].is_extant) {
invariant(is_error); invariant(is_error);
...@@ -208,7 +208,7 @@ int brtloader_fi_reopen (struct file_infos *fi, FIDX idx, const char *mode) { ...@@ -208,7 +208,7 @@ int brtloader_fi_reopen (struct file_infos *fi, FIDX idx, const char *mode) {
invariant(i>=0 && i<fi->n_files); invariant(i>=0 && i<fi->n_files);
invariant(!fi->file_infos[i].is_open); invariant(!fi->file_infos[i].is_open);
invariant(fi->file_infos[i].is_extant); invariant(fi->file_infos[i].is_extant);
fi->file_infos[i].file = fopen(fi->file_infos[i].fname, mode); fi->file_infos[i].file = toku_os_fopen(fi->file_infos[i].fname, mode);
if (fi->file_infos[i].file == NULL) { if (fi->file_infos[i].file == NULL) {
result = errno; result = errno;
} else { } else {
...@@ -224,12 +224,13 @@ int brtloader_fi_reopen (struct file_infos *fi, FIDX idx, const char *mode) { ...@@ -224,12 +224,13 @@ int brtloader_fi_reopen (struct file_infos *fi, FIDX idx, const char *mode) {
int brtloader_fi_close (struct file_infos *fi, FIDX idx) int brtloader_fi_close (struct file_infos *fi, FIDX idx)
{ {
{ int r2 = toku_pthread_mutex_lock(&fi->lock); resource_assert(r2==0); } { int r2 = toku_pthread_mutex_lock(&fi->lock); resource_assert(r2==0); }
invariant(fi->n_files_open>0); invariant(fi->n_files_open>0); // ### loader-cleanup-test failure
fi->n_files_open--; fi->n_files_open--;
invariant(idx.idx >=0 && idx.idx < fi->n_files); invariant(idx.idx >=0 && idx.idx < fi->n_files);
invariant(fi->file_infos[idx.idx].is_open); invariant(fi->file_infos[idx.idx].is_open);
fi->file_infos[idx.idx].is_open = FALSE; fi->file_infos[idx.idx].is_open = FALSE;
int r = fclose(fi->file_infos[idx.idx].file); int r = toku_os_fclose(fi->file_infos[idx.idx].file);
lazy_assert(r == 0); // Barry added this 5/18 // ### loader-cleanup-test failure
{ int r2 = toku_pthread_mutex_unlock(&fi->lock); resource_assert(r2==0); } { int r2 = toku_pthread_mutex_unlock(&fi->lock); resource_assert(r2==0); }
if (r!=0) return errno; if (r!=0) return errno;
else return 0; else return 0;
...@@ -265,7 +266,7 @@ int brtloader_open_temp_file (BRTLOADER bl, FIDX *file_idx) ...@@ -265,7 +266,7 @@ int brtloader_open_temp_file (BRTLOADER bl, FIDX *file_idx)
if (fd < 0) { if (fd < 0) {
result = errno; result = errno;
} else { } else {
f = fdopen(fd, "r+"); f = toku_os_fdopen(fd, "r+");
if (f == NULL) if (f == NULL)
result = errno; result = errno;
else else
...@@ -273,11 +274,11 @@ int brtloader_open_temp_file (BRTLOADER bl, FIDX *file_idx) ...@@ -273,11 +274,11 @@ int brtloader_open_temp_file (BRTLOADER bl, FIDX *file_idx)
} }
if (result != 0) { if (result != 0) {
if (fd >= 0) { if (fd >= 0) {
close(fd); toku_os_close(fd);
unlink(fname); unlink(fname);
} }
if (f != NULL) if (f != NULL)
fclose(f); toku_os_fclose(f); // don't check for error because we're already in an error case
if (fname != NULL) if (fname != NULL)
toku_free(fname); toku_free(fname);
} }
...@@ -309,7 +310,7 @@ static void brtloader_destroy (BRTLOADER bl, BOOL is_error) { ...@@ -309,7 +310,7 @@ static void brtloader_destroy (BRTLOADER bl, BOOL is_error) {
destroy_rowset(&bl->primary_rowset); destroy_rowset(&bl->primary_rowset);
for (int i=0; i<bl->N; i++) { for (int i=0; i<bl->N; i++) {
invariant(bl->fractal_queues[i]==NULL); // !!! If this isn't true, we may have to kill the pthreads and destroy the fractal trees. For now just barf. invariant(bl->fractal_queues[i]==NULL); // !!! If this isn't true, we may have to kill the pthreads and destroy the fractal trees. For now just barf. // ### loader-cleanup-test failure
} }
toku_free(bl->fractal_threads); toku_free(bl->fractal_threads);
toku_free(bl->fractal_queues); toku_free(bl->fractal_queues);
...@@ -2191,7 +2192,7 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl, ...@@ -2191,7 +2192,7 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl,
error: error:
{ {
int rr = close(fd); int rr = toku_os_close(fd);
if (rr) if (rr)
result = errno; result = errno;
} }
...@@ -2258,7 +2259,7 @@ static int loader_do_i (BRTLOADER bl, ...@@ -2258,7 +2259,7 @@ static int loader_do_i (BRTLOADER bl,
{ {
mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO; mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO;
int fd = open(new_fname, O_RDWR| O_CREAT | O_BINARY, mode); int fd = toku_os_open(new_fname, O_RDWR| O_CREAT | O_BINARY, mode); // #2621
if (fd < 0) { if (fd < 0) {
r = errno; goto error; r = errno; goto error;
} }
......
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
db_env_set_func_full_pwrite; db_env_set_func_full_pwrite;
db_env_set_func_write; db_env_set_func_write;
db_env_set_func_full_write; db_env_set_func_full_write;
db_env_set_func_fdopen;
db_env_set_func_fopen;
db_env_set_func_open;
db_env_set_func_fclose;
db_env_set_func_loader_fwrite; db_env_set_func_loader_fwrite;
db_env_set_checkpoint_callback; db_env_set_checkpoint_callback;
db_env_set_checkpoint_callback2; db_env_set_checkpoint_callback2;
......
...@@ -5627,6 +5627,21 @@ int db_env_set_func_full_write (ssize_t (*write_function)(int, const void *, siz ...@@ -5627,6 +5627,21 @@ int db_env_set_func_full_write (ssize_t (*write_function)(int, const void *, siz
return toku_set_func_full_write(write_function); return toku_set_func_full_write(write_function);
} }
int db_env_set_func_fdopen (FILE * (*fdopen_function)(int, const char *)) {
return toku_set_func_fdopen(fdopen_function);
}
int db_env_set_func_fopen (FILE * (*fopen_function)(const char *, const char *)) {
return toku_set_func_fopen(fopen_function);
}
int db_env_set_func_open (int (*open_function)(const char *, int, int)) {
return toku_set_func_open(open_function);
}
int db_env_set_func_fclose (int (*fclose_function)(FILE*)) {
return toku_set_func_fclose(fclose_function);
}
void void
db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) { db_env_set_func_loader_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) {
brtloader_set_os_fwrite(fwrite_fun); brtloader_set_os_fwrite(fwrite_fun);
......
...@@ -63,6 +63,7 @@ typedef int64_t toku_off_t; ...@@ -63,6 +63,7 @@ typedef int64_t toku_off_t;
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <stdio.h>
#endif #endif
...@@ -75,6 +76,7 @@ typedef int64_t toku_off_t; ...@@ -75,6 +76,7 @@ typedef int64_t toku_off_t;
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdio.h>
#if __FreeBSD__ #if __FreeBSD__
#include <stdarg.h> #include <stdarg.h>
#endif #endif
...@@ -156,6 +158,14 @@ void toku_os_full_write (int fd, const void *buf, size_t len) __attribute__((__v ...@@ -156,6 +158,14 @@ void toku_os_full_write (int fd, const void *buf, size_t len) __attribute__((__v
ssize_t toku_os_pwrite (int fd, const void *buf, size_t len, toku_off_t off) __attribute__((__visibility__("default"))); ssize_t toku_os_pwrite (int fd, const void *buf, size_t len, toku_off_t off) __attribute__((__visibility__("default")));
int toku_os_write (int fd, const void *buf, size_t len) __attribute__((__visibility__("default"))); int toku_os_write (int fd, const void *buf, size_t len) __attribute__((__visibility__("default")));
// wrappers around file system calls
FILE * toku_os_fdopen(int fildes, const char *mode);
FILE * toku_os_fopen(const char *filename, const char *mode);
int toku_os_open(const char *path, int oflag, int mode);
int toku_os_close(int fd);
int toku_os_fclose(FILE * stream);
// wrapper around fsync // wrapper around fsync
int toku_file_fsync_without_accounting(int fd); int toku_file_fsync_without_accounting(int fd);
int toku_file_fsync(int fd); int toku_file_fsync(int fd);
...@@ -172,10 +182,15 @@ int toku_set_func_fsync (int (*fsync_function)(int)); ...@@ -172,10 +182,15 @@ int toku_set_func_fsync (int (*fsync_function)(int));
int toku_set_func_malloc (void *(*)(size_t)); int toku_set_func_malloc (void *(*)(size_t));
int toku_set_func_realloc (void *(*)(void*,size_t)); int toku_set_func_realloc (void *(*)(void*,size_t));
int toku_set_func_free (void (*)(void*)); int toku_set_func_free (void (*)(void*));
int toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, toku_off_t)); int toku_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t));
int toku_set_func_full_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, toku_off_t)); int toku_set_func_full_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t));
int toku_set_func_write (ssize_t (*pwrite_fun)(int, const void *, size_t)); int toku_set_func_write (ssize_t (*)(int, const void *, size_t));
int toku_set_func_full_write (ssize_t (*pwrite_fun)(int, const void *, size_t)); int toku_set_func_full_write (ssize_t (*)(int, const void *, size_t));
int toku_set_func_fdopen (FILE * (*)(int, const char *));
int toku_set_func_fopen (FILE * (*)(const char *, const char *));
int toku_set_func_open (int (*)(const char *, int, int)); // variadic form not implemented until needed
int toku_set_func_fclose(int (*)(FILE*));
int toku_portability_init (void); int toku_portability_init (void);
int toku_portability_destroy (void); int toku_portability_destroy (void);
......
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