util: avoid fds leak when virEventPollAddHandle fail

* src/util/event_poll.c: avoid file descriptors leak when
  virEventPollAddHandle fail on virEventPollInit function.
This commit is contained in:
Alex Jia
2011-07-19 07:22:27 -06:00
committed by Eric Blake
parent 74594c57f1
commit 463e8c2ff0
+3
View File
@@ -36,6 +36,7 @@
#include "event_poll.h"
#include "memory.h"
#include "util.h"
#include "files.h"
#include "ignore-value.h"
#include "virterror_internal.h"
@@ -657,6 +658,8 @@ int virEventPollInit(void)
virEventError(VIR_ERR_INTERNAL_ERROR,
_("Unable to add handle %d to event loop"),
eventLoop.wakeupfd[0]);
VIR_FORCE_CLOSE(eventLoop.wakeupfd[0]);
VIR_FORCE_CLOSE(eventLoop.wakeupfd[1]);
return -1;
}