From 7f84d4b7a4a8b732716c29b4d1f6b358878efd79 Mon Sep 17 00:00:00 2001 From: Yoni Fogel Date: Wed, 12 Jun 2013 08:31:32 -0700 Subject: [PATCH] refs #25. Fix (test-only) bug where db_env_set_toku_product_name would not get called for some tests because they were lower than ydb layer --- ft/ft-ops.cc | 2 ++ ft/ft.cc | 19 +++++++++++++++++++ ft/ft.h | 1 + src/ydb.cc | 5 ----- src/ydb_env_func.cc | 18 ------------------ src/ydb_env_func.h | 2 -- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/ft/ft-ops.cc b/ft/ft-ops.cc index bf09eca7178..9d7f61c2aca 100644 --- a/ft/ft-ops.cc +++ b/ft/ft-ops.cc @@ -6209,6 +6209,8 @@ int toku_ft_layer_init(void) { //Portability must be initialized first r = toku_portability_init(); if (r) { goto exit; } + r = db_env_set_toku_product_name("tokudb"); + if (r) { goto exit; } partitioned_counters_init(); status_init(); diff --git a/ft/ft.cc b/ft/ft.cc index ed2d851f6c6..beb70fa0f85 100644 --- a/ft/ft.cc +++ b/ft/ft.cc @@ -1170,3 +1170,22 @@ toku_single_process_unlock(int *lockfd) { return 0; } +int tokudb_num_envs = 0; +int +db_env_set_toku_product_name(const char *name) { + if (tokudb_num_envs > 0) { + return EINVAL; + } + if (!name || strlen(name) < 1) { + return EINVAL; + } + if (strlen(name) >= sizeof(toku_product_name)) { + return ENAMETOOLONG; + } + if (strncmp(toku_product_name, name, sizeof(toku_product_name))) { + strcpy(toku_product_name, name); + tokudb_update_product_name_strings(); + } + return 0; +} + diff --git a/ft/ft.h b/ft/ft.h index 1289ee69513..8fce78b1a9f 100644 --- a/ft/ft.h +++ b/ft/ft.h @@ -215,4 +215,5 @@ struct toku_product_name_strings_struct { }; extern struct toku_product_name_strings_struct toku_product_name_strings; +extern int tokudb_num_envs; #endif diff --git a/src/ydb.cc b/src/ydb.cc index ff4868fdb0d..3d7a1c565dc 100644 --- a/src/ydb.cc +++ b/src/ydb.cc @@ -238,9 +238,6 @@ toku_ydb_init(void) { int r = 0; //Lower level must be initialized first. r = toku_ft_layer_init(); - if (r!=0) goto exit; - r = db_env_set_toku_product_name("tokudb"); -exit: return r; } @@ -2230,8 +2227,6 @@ env_get_cursor_for_directory(DB_ENV* env, DB_TXN* txn, DBC** c) { return toku_db_cursor(env->i->directory, txn, c, 0); } -int tokudb_num_envs = 0; - static int toku_env_create(DB_ENV ** envp, uint32_t flags) { int r = ENOSYS; diff --git a/src/ydb_env_func.cc b/src/ydb_env_func.cc index 2190dace55e..98450b427b5 100644 --- a/src/ydb_env_func.cc +++ b/src/ydb_env_func.cc @@ -226,21 +226,3 @@ db_env_set_num_bucket_mutexes(uint32_t num_mutexes) { toku_pair_list_set_lock_size(num_mutexes); } -int -db_env_set_toku_product_name(const char *name) { - if (tokudb_num_envs > 0) { - return EINVAL; - } - if (!name || strlen(name) < 1) { - return EINVAL; - } - if (strlen(name) >= sizeof(toku_product_name)) { - return ENAMETOOLONG; - } - if (strncmp(toku_product_name, name, sizeof(toku_product_name))) { - strcpy(toku_product_name, name); - tokudb_update_product_name_strings(); - } - return 0; -} - diff --git a/src/ydb_env_func.h b/src/ydb_env_func.h index 8e57088d8bd..9ebad8d8862 100644 --- a/src/ydb_env_func.h +++ b/src/ydb_env_func.h @@ -105,6 +105,4 @@ void setup_dlmalloc(void) __attribute__((__visibility__("default"))); // Test-only function void toku_env_increase_last_xid(DB_ENV *env, uint64_t increment); -extern int tokudb_num_envs; - #endif