[libvirt] [PATCH] unlock eventLoop before calling callback function

Eric Blake eblake at redhat.com
Mon Mar 7 16:12:24 UTC 2011


On 03/07/2011 06:27 AM, Jiri Denemark wrote:
> And the rest of the for loops in Cleanup* is safe as well for the reason you
> already mentioned. The code moves stuff from i+1 to the end of the array one
> position closer the beginning of the array and it will move the possibly added
> items as well. The only thing which may happen is that if Remove* is called
> while the mutex is unlocked, an item which we already went through can be
> marked as deleted so we are no longer guaranteed that when Cleanup* finishes,
> the array only contains items which were not deleted. But AFAICT no-one counts
> with that behavior so it's safe to break it.

Actually, someone does count on it:

virEventRunOnce first runs the cleanup handlers, then calls
virEventMakePollFDs, all while holding the lock.  virEventMakePollFDs
currently adds a slot in the poll fd array for every slot of the array,
because it "knows" that there are no deleted entries in the array (since
the cleanup completed without dropping lock).

Once we make the cleanup functions drop and regain lock, we also need to
teach virEventMakePollFDs to ignore deleted entries.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110307/b09fc99f/attachment-0001.sig>


More information about the libvir-list mailing list