Commit a5532e30 authored by gejun's avatar gejun

move a signal outside lock

parent 9fd180ef
...@@ -163,7 +163,7 @@ void EndRunningUserCodeInPool(void (*fn)(void*), void* arg) { ...@@ -163,7 +163,7 @@ void EndRunningUserCodeInPool(void (*fn)(void*), void* arg) {
// all workers from being blocked and no responses will be processed // all workers from being blocked and no responses will be processed
// anymore (deadlocked). // anymore (deadlocked).
const UserCode usercode = { fn, arg }; const UserCode usercode = { fn, arg };
BAIDU_SCOPED_LOCK(s_usercode_mutex); pthread_mutex_lock(&s_usercode_mutex);
s_usercode_pool->queue.push_back(usercode); s_usercode_pool->queue.push_back(usercode);
// If the queue has too many items, we can't drop the user code // If the queue has too many items, we can't drop the user code
// directly which often must be run, for example: client-side done. // directly which often must be run, for example: client-side done.
...@@ -175,6 +175,7 @@ void EndRunningUserCodeInPool(void (*fn)(void*), void* arg) { ...@@ -175,6 +175,7 @@ void EndRunningUserCodeInPool(void (*fn)(void*), void* arg) {
FLAGS_max_pending_in_each_backup_thread)) { FLAGS_max_pending_in_each_backup_thread)) {
g_too_many_usercode = true; g_too_many_usercode = true;
} }
pthread_mutex_unlock(&s_usercode_mutex);
pthread_cond_signal(&s_usercode_cond); pthread_cond_signal(&s_usercode_cond);
} }
......
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