]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
util: avoid fds leak when virEventPollAddHandle fail
authorAlex Jia <ajia@redhat.com>
Tue, 19 Jul 2011 11:15:18 +0000 (19:15 +0800)
committerEric Blake <eblake@redhat.com>
Tue, 19 Jul 2011 13:22:27 +0000 (07:22 -0600)
* src/util/event_poll.c: avoid file descriptors leak when
  virEventPollAddHandle fail on virEventPollInit function.

src/util/event_poll.c

index 285ba5056ce01371aa3a07be49044d229d3e7789..e2ae3a64e6394c78af8e817d71ad30830d55e42d 100644 (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;
     }