Commit 87bbf72c authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Addresses #2121 refs[t:2121] toku_ydb_lock_destroy(): After freeing...

Addresses #2121 refs[t:2121] toku_ydb_lock_destroy(): After freeing thread-specific memory for ydbtime struct, 
set thread-specific storage to NULL to prevent destructor (toku_free) from being called twice,
just in case the thread that calls toku_ydb_lock_destroy() is not the same thread that called 
toku_ydb_lock_init().


git-svn-id: file:///svn/toku/tokudb@15976 c7de825b-a66e-492c-adef-691d508d4ae1
parent c2d7c68f
......@@ -107,8 +107,15 @@ toku_ydb_lock_destroy(void) {
int r;
r = toku_pthread_mutex_destroy(&ydb_big_lock.lock); assert(r == 0);
#if YDB_LOCK_MISS_TIME
// If main thread calls here, free memory allocated to main thread
// because destructor would not be called on thread exit.
void * last_ydbtime = toku_pthread_getspecific(ydb_big_lock.time_key);
if (last_ydbtime) toku_free(last_ydbtime);
// If some other thread (not main thread) calls here
// set the value to NULL so destructor is not called twice
r = toku_pthread_setspecific(ydb_big_lock.time_key, NULL); assert(r==0);
r = toku_pthread_key_delete(ydb_big_lock.time_key); assert(r == 0);
#endif
return r;
......
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