mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 12:42:54 +00:00
dm: safely use pthread_cond_broadcast()
Use pthread_cond_broadcast() while holding the mutex to guarantee the signaling of its condition variable. Tracked-On: #2763 Signed-off-by: Peter Fang <peter.fang@intel.com> Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
parent
fa375a2aa1
commit
18aebc0196
@ -925,8 +925,9 @@ blockif_close(struct blockif_ctxt *bc)
|
||||
*/
|
||||
pthread_mutex_lock(&bc->mtx);
|
||||
bc->closing = 1;
|
||||
pthread_mutex_unlock(&bc->mtx);
|
||||
pthread_cond_broadcast(&bc->cond);
|
||||
pthread_mutex_unlock(&bc->mtx);
|
||||
|
||||
for (i = 0; i < BLOCKIF_NUMTHR; i++)
|
||||
pthread_join(bc->btid[i], &jval);
|
||||
|
||||
|
@ -295,9 +295,10 @@ virtio_net_tx_stop(struct virtio_net *net)
|
||||
{
|
||||
void *jval;
|
||||
|
||||
pthread_mutex_lock(&net->tx_mtx);
|
||||
net->closing = 1;
|
||||
|
||||
pthread_cond_broadcast(&net->tx_cond);
|
||||
pthread_mutex_unlock(&net->tx_mtx);
|
||||
|
||||
pthread_join(net->tx_tid, &jval);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user