[libvirt] [PATCH v3] util: avoid fds leak when virEventPollAddHandle fail

ajia at redhat.com ajia at redhat.com
Tue Jul 19 11:15:18 UTC 2011


* src/util/event_poll.c: avoid file descriptors leak when 
  virEventPollAddHandle fail on virEventPollInit function.
---
 src/util/event_poll.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/util/event_poll.c b/src/util/event_poll.c
index 285ba50..e2ae3a6 100644
--- a/src/util/event_poll.c
+++ b/src/util/event_poll.c
@@ -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;
     }
 
-- 
1.7.1




More information about the libvir-list mailing list