[FIX] Fix potential race condition

This commit is contained in:
LDA 2024-08-19 00:24:00 +02:00
commit 1f747dd016

View file

@ -331,6 +331,7 @@ ParseeAwaitStanza(char *identifier, int64_t timeout)
{ {
/* Timeout detected, give up regardless of the status of our /* Timeout detected, give up regardless of the status of our
* search. */ * search. */
pthread_mutex_lock(&await_lock);
HashMapDelete(await_table, identifier); HashMapDelete(await_table, identifier);
pthread_mutex_unlock(&await_lock); pthread_mutex_unlock(&await_lock);
break; break;
@ -344,7 +345,9 @@ ParseeAwaitStanza(char *identifier, int64_t timeout)
stanza = awa.stanza; stanza = awa.stanza;
pthread_mutex_unlock(&awa.cond_lock); pthread_mutex_unlock(&awa.cond_lock);
pthread_mutex_lock(&await_lock);
pthread_cond_destroy(&awa.condition); pthread_cond_destroy(&awa.condition);
pthread_mutex_destroy(&awa.cond_lock); pthread_mutex_destroy(&awa.cond_lock);
pthread_mutex_unlock(&await_lock);
return stanza; return stanza;
} }