Commit 13e28a3e authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1296

Global mutexes are now initialized in toku_ydb_init, destroyed in toku_ydb_destroy.

Globals in tdbtrace.c (not default) are not yet initialized.

git-svn-id: file:///svn/toku/tokudb.1032b@8149 c7de825b-a66e-492c-adef-691d508d4ae1
parent 946dd25a
......@@ -46,6 +46,14 @@ static void maybe_preallocate_in_file (int fd, u_int64_t size) {
static toku_pthread_mutex_t pwrite_mutex = TOKU_PTHREAD_MUTEX_INITIALIZER;
static int pwrite_is_locked=0;
void toku_pwrite_lock_init(void) {
int r = toku_pthread_mutex_init(&pwrite_mutex, NULL); assert(r == 0);
}
void toku_pwrite_lock_destroy(void) {
int r = toku_pthread_mutex_destroy(&pwrite_mutex); assert(r == 0);
}
static inline void
lock_for_pwrite (void) {
// Locks the pwrite_mutex.
......
......@@ -4282,3 +4282,20 @@ int toku_brt_truncate (BRT brt) {
return r;
}
static void toku_brt_lock_init(void) {
toku_pwrite_lock_init();
}
static void toku_brt_lock_destroy(void) {
toku_pwrite_lock_destroy();
}
void toku_brt_init(void) {
toku_brt_lock_init();
}
void toku_brt_destroy(void) {
toku_brt_lock_destroy();
}
......@@ -113,4 +113,8 @@ int toku_brt_keyrange (BRT brt, DBT *key, u_int64_t *less, u_int64_t *equal, u
void extend_block_translation (BLOCKNUM blocknum, struct brt_header *h);
void toku_brt_init(void);
void toku_brt_destroy(void);
void toku_pwrite_lock_init(void);
void toku_pwrite_lock_destroy(void);
#endif
......@@ -42,10 +42,12 @@ const char *toku_copyright_string = "Copyright (c) 2007, 2008 Tokutek Inc. All
const u_int32_t __toku_env_default_max_locks = 1000;
void toku_ydb_init(void) {
toku_brt_init();
toku_ydb_lock_init();
}
void toku_ydb_destroy(void) {
toku_brt_destroy();
toku_ydb_lock_destroy();
}
......
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