1
0
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:
Daniel P. Berrange
2009-08-24 17:27:55 +01:00
parent 77a1f418c8
commit 34d22c1ed5
2 changed files with 57 additions and 16 deletions

View File

@@ -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);