From f2e62de7d99ae4061e72e313d3aa9779a15839a9 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sun, 15 Mar 2015 16:18:03 +0000 Subject: [PATCH] Close potential race on blockif_close(). Reported by: vangyzen MFC after: 2 weeks --- usr.sbin/bhyve/block_if.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c index 68a9bae9c901..58960ca0c757 100644 --- a/usr.sbin/bhyve/block_if.c +++ b/usr.sbin/bhyve/block_if.c @@ -579,7 +579,9 @@ blockif_close(struct blockif_ctxt *bc) /* * Stop the block i/o thread */ + pthread_mutex_lock(&bc->bc_mtx); bc->bc_closing = 1; + pthread_mutex_unlock(&bc->bc_mtx); pthread_cond_broadcast(&bc->bc_cond); for (i = 0; i < BLOCKIF_NUMTHR; i++) pthread_join(bc->bc_btid[i], &jval);