diff --git a/ft/ftloader.cc b/ft/ftloader.cc index 7214ee10039..67b3cf9905e 100644 --- a/ft/ftloader.cc +++ b/ft/ftloader.cc @@ -356,6 +356,8 @@ int ft_loader_open_temp_file (FTLOADER bl, FIDX *file_idx) */ { int result = 0; + if (result) // debug hack + return result; FILE *f = NULL; int fd = -1; char *fname = toku_strdup(bl->temp_file_template); @@ -2430,6 +2432,8 @@ static int toku_loader_write_ft_from_q (FTLOADER bl, if (r) { result = r; drain_writer_q(q); + r = toku_os_close(fd); + assert_zero(r); return result; } FILE *pivots_stream = toku_bl_fidx2file(bl, pivots_file); diff --git a/src/tests/loader-close-nproc-limit.cc b/src/tests/loader-close-nproc-limit.cc index eee15faa1d3..3ef2b0541f7 100644 --- a/src/tests/loader-close-nproc-limit.cc +++ b/src/tests/loader-close-nproc-limit.cc @@ -85,6 +85,9 @@ PATENT RIGHTS GRANT: under this License. */ +// Verify that loader->close works correctly (does not crash, does not leak memory, returns the right error code) +// when the NPROC limit is exceeded. + #ident "Copyright (c) 2010-2013 Tokutek Inc. All rights reserved." #ident "$Id$" @@ -95,11 +98,7 @@ PATENT RIGHTS GRANT: static int loader_flags = 0; static const char *envdir = TOKU_TEST_FILENAME; -static int put_multiple_generate(DB *UU(dest_db), DB *UU(src_db), DBT_ARRAY *UU(dest_keys), DBT_ARRAY *UU(dest_vals), const DBT *UU(src_key), const DBT *UU(src_val)) { - return ENOMEM; -} - -static void loader_open_close(int ndb) { +static void run_test(int ndb) { int r; char rmcmd[32 + strlen(envdir)]; @@ -109,8 +108,6 @@ static void loader_open_close(int ndb) { DB_ENV *env; r = db_env_create(&env, 0); CKERR(r); - r = env->set_generate_row_callback_for_put(env, put_multiple_generate); - CKERR(r); int envflags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE; r = env->open(env, envdir, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); env->set_errfile(env, stderr); @@ -196,6 +193,6 @@ static void do_args(int argc, char * const argv[]) { int test_main(int argc, char * const *argv) { do_args(argc, argv); - loader_open_close(1); + run_test(1); return 0; } diff --git a/src/tests/loader-create-close.cc b/src/tests/loader-create-close.cc index 6a04387152f..4d66a9df004 100644 --- a/src/tests/loader-create-close.cc +++ b/src/tests/loader-create-close.cc @@ -97,11 +97,7 @@ PATENT RIGHTS GRANT: static int loader_flags = 0; static const char *envdir = TOKU_TEST_FILENAME; -static int put_multiple_generate(DB *UU(dest_db), DB *UU(src_db), DBT_ARRAY *UU(dest_keys), DBT_ARRAY *UU(dest_vals), const DBT *UU(src_key), const DBT *UU(src_val)) { - return ENOMEM; -} - -static void loader_open_abort(int ndb) { +static void test_loader_create_close(int ndb) { int r; char rmcmd[32 + strlen(envdir)]; @@ -111,8 +107,6 @@ static void loader_open_abort(int ndb) { DB_ENV *env; r = db_env_create(&env, 0); CKERR(r); - r = env->set_generate_row_callback_for_put(env, put_multiple_generate); - CKERR(r); int envflags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE; r = env->open(env, envdir, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); env->set_errfile(env, stderr); @@ -181,8 +175,8 @@ static void do_args(int argc, char * const argv[]) { int test_main(int argc, char * const *argv) { do_args(argc, argv); - loader_open_abort(0); - loader_open_abort(1); - loader_open_abort(2); + test_loader_create_close(0); + test_loader_create_close(1); + test_loader_create_close(2); return 0; } diff --git a/src/tests/loader-create-commit-nproc-limit.cc b/src/tests/loader-create-commit-nproc-limit.cc index 26ce5e478ed..091809a8551 100644 --- a/src/tests/loader-create-commit-nproc-limit.cc +++ b/src/tests/loader-create-commit-nproc-limit.cc @@ -99,7 +99,7 @@ PATENT RIGHTS GRANT: static int loader_flags = 0; static const char *envdir = TOKU_TEST_FILENAME; -static void loader_create_commit(int ndb) { +static void run_test(int ndb) { int r; char rmcmd[32 + strlen(envdir)]; @@ -206,6 +206,6 @@ static void do_args(int argc, char * const argv[]) { int test_main(int argc, char * const *argv) { do_args(argc, argv); - loader_create_commit(1); + run_test(1); return 0; } diff --git a/src/tests/loader-create-nproc-limit.cc b/src/tests/loader-create-nproc-limit.cc index 09f57c9019c..7a61fce7799 100644 --- a/src/tests/loader-create-nproc-limit.cc +++ b/src/tests/loader-create-nproc-limit.cc @@ -85,6 +85,9 @@ PATENT RIGHTS GRANT: under this License. */ +// Verify that env->create_loader works correctly (does not crash, does not leak memory, returns the right error code) +// when the NPROC limit is exceeded. + #ident "Copyright (c) 2010-2013 Tokutek Inc. All rights reserved." #ident "$Id$" @@ -95,11 +98,7 @@ PATENT RIGHTS GRANT: static int loader_flags = 0; static const char *envdir = TOKU_TEST_FILENAME; -static int put_multiple_generate(DB *UU(dest_db), DB *UU(src_db), DBT_ARRAY *UU(dest_keys), DBT_ARRAY *UU(dest_vals), const DBT *UU(src_key), const DBT *UU(src_val)) { - return ENOMEM; -} - -static void loader_open_close(int ndb) { +static void run_test(int ndb) { int r; char rmcmd[32 + strlen(envdir)]; @@ -109,8 +108,6 @@ static void loader_open_close(int ndb) { DB_ENV *env; r = db_env_create(&env, 0); CKERR(r); - r = env->set_generate_row_callback_for_put(env, put_multiple_generate); - CKERR(r); int envflags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_PRIVATE; r = env->open(env, envdir, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); env->set_errfile(env, stderr); @@ -197,6 +194,6 @@ static void do_args(int argc, char * const argv[]) { int test_main(int argc, char * const *argv) { do_args(argc, argv); - loader_open_close(1); + run_test(1); return 0; }