[libvirt] [PATCH] util: eventpoll: Survive EBADF on macOS

Daniel P. Berrangé berrange at redhat.com
Thu Aug 23 07:06:51 UTC 2018


On Thu, Aug 23, 2018 at 01:54:46AM +0300, Roman Bolshakov wrote:
> On Wed, Aug 22, 2018 at 10:41:18AM +0100, Daniel P. Berrangé wrote:
> > I don't think we should go through the dispatch code when
> > we get EBADF, as the contents of the 'revents' fields are
> > undefined after we get an error.
> > 
> > We should jump straight to the end where we have
> > "eventLoop.running = 0;"
> > 
> > If any FDs were in fact ready, we'll get them on the next iteration of
> > the loop anyway.
> > 
> 
> Alright, but the thread won't hold evenLoop.lock after such jump and
> virMutexUnlock may fail with ENOPERM. I suppose that could confuse
> valgrind & friends.
> What if we change eventLoop.running to 0 under the eventLoop.lock right in
> the macOS EBADF handler and then return?

Nah, just call virMutexLock before doing the jump.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list