mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-10-20 11:33:43 +03:00
Avoid polling on FDs with no events enabled
If a file descriptor with events=0 was added to the libvirtd event loop, it would still be added to the poll() fds' array. While it wouldn't see any POLLIN/OUT events, it'd still get triggered for HANGUP/ERROR events which was not in compliance with the libvirt events API contract. * qemud/event.c: Don't poll on FDs with events=0 * tests/eventtest.c: Add test case to validate fix to event.c
This commit is contained in:
@@ -430,6 +430,25 @@ mymain(int argc, char **argv)
|
||||
for (i = 0 ; i < NUM_TIME ; i++)
|
||||
virEventRemoveTimeoutImpl(timers[i].timer);
|
||||
|
||||
resetAll();
|
||||
|
||||
/* Final test, register same FD twice, once with no
|
||||
* events, and make sure the right callback runs */
|
||||
handles[0].pipeFD[0] = handles[1].pipeFD[0];
|
||||
handles[0].pipeFD[1] = handles[1].pipeFD[1];
|
||||
|
||||
handles[0].watch = virEventAddHandleImpl(handles[0].pipeFD[0],
|
||||
0,
|
||||
testPipeReader,
|
||||
&handles[0], NULL);
|
||||
handles[1].watch = virEventAddHandleImpl(handles[1].pipeFD[0],
|
||||
VIR_EVENT_HANDLE_READABLE,
|
||||
testPipeReader,
|
||||
&handles[1], NULL);
|
||||
startJob("Write duplicate", &test);
|
||||
ret = safewrite(handles[1].pipeFD[1], &one, 1);
|
||||
if (finishJob(1, -1) != EXIT_SUCCESS)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
//pthread_kill(eventThread, SIGTERM);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user