Commit f2895078 authored by Dave Wells's avatar Dave Wells Committed by Yoni Fogel

fix memory leak

git-svn-id: file:///svn/toku/tokudb@16258 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9f9280f2
...@@ -79,6 +79,9 @@ static void set_crash_timer(void) { ...@@ -79,6 +79,9 @@ static void set_crash_timer(void) {
static void update_crash_timer(void) { static void update_crash_timer(void) {
if ( --crash_timer == 0 ) { if ( --crash_timer == 0 ) {
// close the states table before we crash
int r = states->close(states, 0);
CKERR(r);
if ( verbose ) { if ( verbose ) {
printf("%s : crash\n", __FILE__); printf("%s : crash\n", __FILE__);
fflush(stdout); fflush(stdout);
...@@ -236,7 +239,7 @@ static void do_random_fileops(void) ...@@ -236,7 +239,7 @@ static void do_random_fileops(void)
} }
} }
static void run_test(int iter, int crash){ static void run_test(int iter){
u_int32_t recovery_flags = DB_INIT_LOG | DB_INIT_TXN; u_int32_t recovery_flags = DB_INIT_LOG | DB_INIT_TXN;
int r, i; int r, i;
...@@ -367,21 +370,10 @@ static void run_test(int iter, int crash){ ...@@ -367,21 +370,10 @@ static void run_test(int iter, int crash){
db_env_set_checkpoint_callback(NULL, NULL); db_env_set_checkpoint_callback(NULL, NULL);
db_env_set_checkpoint_callback2(NULL, NULL); db_env_set_checkpoint_callback2(NULL, NULL);
// after checkpoint // after checkpoint
if ( verbose ) printf("%s : after checkpoint #2\n", __FILE__); if ( verbose ) printf("%s : after checkpoint #2\n", __FILE__);
do_random_fileops(); do_random_fileops();
// close the states table before we crash
r = states->close(states, 0); CKERR(r);
crash = crash;
if (iter > 10 ) {
if ( verbose ) printf("%s : crash\n", __FILE__);
crash_it();
}
if ( verbose ) printf("%s : done\n", __FILE__);
r = env->txn_checkpoint(env, 0, 0, 0); CKERR(r); r = env->txn_checkpoint(env, 0, 0, 0); CKERR(r);
for (i=0;i<NUM_DICTIONARIES;i++) { for (i=0;i<NUM_DICTIONARIES;i++) {
...@@ -393,20 +385,19 @@ static void run_test(int iter, int crash){ ...@@ -393,20 +385,19 @@ static void run_test(int iter, int crash){
} }
} }
r = env->close(env, 0); r = states->close(states, 0); CKERR(r);
// assert((r == 0) || (r == EINVAL)); // OK to have open transactions prior to close r = env->close(env, 0); CKERR(r);
CKERR(r); if ( verbose ) printf("%s : done\n", __FILE__);
} }
// ------------ infrastructure ---------- // ------------ infrastructure ----------
static void do_args(int argc, char *argv[]); static void do_args(int argc, char *argv[]);
static int iter_arg = 0; static int iter_arg = 0;
static int do_crash = 0;
int test_main(int argc, char **argv) { int test_main(int argc, char **argv) {
do_args(argc, argv); do_args(argc, argv);
run_test(iter_arg,do_crash); run_test(iter_arg);
return 0; return 0;
} }
...@@ -423,13 +414,11 @@ static void do_args(int argc, char *argv[]) { ...@@ -423,13 +414,11 @@ static void do_args(int argc, char *argv[]) {
} else if (strcmp(argv[0], "-h")==0) { } else if (strcmp(argv[0], "-h")==0) {
resultcode=0; resultcode=0;
do_usage: do_usage:
fprintf(stderr, "Usage:\n%s [-v|-q]* [-h] [-i] [-C] \n", cmd); fprintf(stderr, "Usage:\n%s [-v|-q]* [-h] [-i] \n", cmd);
exit(resultcode); exit(resultcode);
} else if (strcmp(argv[0], "-i")==0) { } else if (strcmp(argv[0], "-i")==0) {
argc--; argv++; argc--; argv++;
iter_arg = atoi(argv[0]); iter_arg = atoi(argv[0]);
} else if (strcmp(argv[0], "-C")==0) {
do_crash = 1;
} else { } else {
fprintf(stderr, "Unknown arg: %s\n", argv[0]); fprintf(stderr, "Unknown arg: %s\n", argv[0]);
resultcode=1; resultcode=1;
......
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