]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Fix deadlock on libvirtd shutdown
authorJim Fehlig <jfehlig@suse.com>
Thu, 21 Jun 2012 15:21:44 +0000 (09:21 -0600)
committerJim Fehlig <jfehlig@suse.com>
Thu, 21 Jun 2012 17:38:51 +0000 (11:38 -0600)
commit0dda594da99aede7621018a3705e7cf4c13b1606
tree8243daf6cf881322e5a245d7c378c1e269d44235
parentfd4fd420b4d2745be1a99aaf1926b63e1e4f7d8a
Fix deadlock on libvirtd shutdown

When shutting down libvirtd, the virNetServer shutdown can deadlock
if there are in-flight jobs being handled by virNetServerHandleJob().
virNetServerFree() will acquire the virNetServer lock and call
virThreadPoolFree() to terminate the workers, waiting for the workers
to finish.  But in-flight workers will attempt to acquire the
virNetServer lock, resulting in deadlock.

Fix the deadlock by unlocking the virNetServer lock before calling
virThreadPoolFree().  This is safe since the virNetServerPtr object
is ref-counted and only decrementing the ref count needs to be
protected.  Additionally, there is no need to re-acquire the lock
after virThreadPoolFree() completes as all the workers have
terminated.
src/rpc/virnetserver.c