-
Notifications
You must be signed in to change notification settings - Fork 3.4k
A possible deadlock in brain_server_handle_client? #3016
Copy link
Copy link
Open
Description
Hi, it seems there could be a deadlock due to cyclic lock acquisitions between locks mux_hr and mux_hg in the method brain_server_handle_client executed by multiple concurrent threads. Should it be a bug?
void *brain_server_handle_client (void *p)
{
...;
hc_thread_mutex_lock (brain_server_db_hash->mux_hr);
if (brain_server_db_hash->hb == 1)
{
hc_thread_mutex_lock (brain_server_db_hash->mux_hg); // from lock mux_hr to mux_hg
}
hc_thread_mutex_unlock (brain_server_db_hash->mux_hr);
...;
hc_thread_mutex_lock (brain_server_db_hash->mux_hr); // from mux_hg to mux_hr
...;
if (brain_server_db_hash->hb == 0)
{
hc_thread_mutex_unlock (brain_server_db_hash->mux_hg);
}
hc_thread_mutex_unlock (brain_server_db_hash->mux_hr);
...;
}
Lines 2811 to 2820 in 959a232
| hc_thread_mutex_lock (brain_server_db_hash->mux_hr); | |
| brain_server_db_hash->hb--; | |
| if (brain_server_db_hash->hb == 0) | |
| { | |
| hc_thread_mutex_unlock (brain_server_db_hash->mux_hg); | |
| } | |
| hc_thread_mutex_unlock (brain_server_db_hash->mux_hr); |
Lines 2770 to 2779 in 959a232
| hc_thread_mutex_lock (brain_server_db_hash->mux_hr); | |
| brain_server_db_hash->hb++; | |
| if (brain_server_db_hash->hb == 1) | |
| { | |
| hc_thread_mutex_lock (brain_server_db_hash->mux_hg); | |
| } | |
| hc_thread_mutex_unlock (brain_server_db_hash->mux_hr); |
Line 3316 in 959a232
| hc_thread_create (client_thr, brain_server_handle_client, &brain_server_client_options[client_idx]); |
Best,
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels