[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH 2/3] Avoid race conditions when nbdkit exits.



On 11/14/2017 11:30 AM, Richard W.M. Jones wrote:
> There are several race conditions where nbdkit exits (calling
> plugin_cleanup() which unloads the plugin), while the plugin is either
> in a callback or in plugin.close().
> 
> Avoid these by:
> 
> (1) Taking a shared lock around all plugin callbacks.
> 
> (2) Taking the same as an exclusive lock in plugin_cleanup.
> 
> This delays plugin_cleanup until all callbacks have finished.
> 
> (3) Removing a few unnecessary ‘assert (dl)’.
> 
> This is necessary because the plugin can now be unloaded while holding
> locks.  ‘dl’ is not needed to lock or unlock the plugin so asserting
> it is useless.
> 
> (4) Don't call plugin.close on the quit path.
> 
> Another thread could be unloading the plugin so we cannot call
> the .close callback.

Yes, this looks like it solves the same race in a much nicer manner.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]