util: eventpoll: Survive EBADF on macOS
Fixes: https://www.redhat.com/archives/libvir-list/2017-January/msg00978.html QEMU is probed through monitor fd to check capabilities during libvirtd init. The monitor fd is closed after probing by virQEMUCapsInitQMPCommandFree that calls virQEMUCapsInitQMPCommandAbort that calls qemuMonitorClose, the latter one notifies the event loop via an interrupt handle in qemuMonitorUnregister and after then closes monitor fd. There could be a case when interrupt is sent after eventLoop is unlocked but before virEventPollRunOnce blocks in poll, shortly before file descriptor is closed by qemuMonitorClose. Then poll receives closed monitor fd in fdset and returns EBADF. EBADF is not mentioned as a valid errno on macOS poll man-page but such behaviour can appear release-to-release, according to cpython: https://github.com/python/cpython/blob/master/Modules/selectmodule.c#L1161 The change also fixes the issue in qemucapabilitiestest. It returns Bad file descriptor message 25 times without the fix. Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com> Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Showing
想要评论请 注册 或 登录