]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Fix log locking problem when using fork() in the library
authorCole Robinson <crobinso@redhat.com>
Wed, 3 Feb 2010 16:12:57 +0000 (17:12 +0100)
committerDaniel Veillard <veillard@redhat.com>
Wed, 3 Feb 2010 16:12:57 +0000 (17:12 +0100)
commitcd0ef0e09b718d8574f1b94d449e72c5469f9924
treed9ac4f8e618025807a64e39aea650018dc25105e
parent8d42b9b4e8f15581bd611ee6aa0cc37c201ff6e7
Fix log locking problem when using fork() in the library

Ad pointed out by Dan Berrange:
So if some thread in libvirtd is currently executing a logging call,
while another thread calls virExec(), that other thread no longer
exists in the child, but its lock is never released. So when the
child then does virLogReset() it deadlocks.

The only way I see to address this, is for the parent process to call
virLogLock(), immediately before fork(), and then virLogUnlock()
afterwards in both parent & child. This will ensure that no other
thread
can be holding the lock across fork().

* src/util/logging.[ch] src/libvirt_private.syms: export virLogLock() and
  virLogUnlock()
* src/util/util.c: lock just before forking and unlock just after - in
  both parent and child.
src/libvirt_private.syms
src/util/logging.c
src/util/logging.h
src/util/util.c