Browse files

Fix a file descriptor leak in BackgroundEventLoop.

  • Loading branch information...
1 parent 71dd266 commit caf5698d3040bc9ea1aaac4b9e1f8912653940c9 @FooBarWidget FooBarWidget committed Apr 25, 2013
Showing with 5 additions and 11 deletions.
  1. +5 −11 ext/common/BackgroundEventLoop.cpp
View
16 ext/common/BackgroundEventLoop.cpp
@@ -63,17 +63,7 @@ startBackgroundLoop(BackgroundEventLoop *bg) {
BackgroundEventLoop::BackgroundEventLoop(bool scalable) {
TRACE_POINT();
- loop = ev_loop_new(EVBACKEND_EPOLL);
- if (loop == NULL) {
- loop = ev_loop_new(EVBACKEND_KQUEUE);
- }
- if (loop == NULL) {
- loop = ev_loop_new(0);
- }
- if (loop == NULL) {
- throw RuntimeException("Cannot create an event loop");
- }
-
+
if (scalable) {
loop = ev_loop_new(EVBACKEND_KQUEUE);
if (loop == NULL) {
@@ -85,6 +75,10 @@ BackgroundEventLoop::BackgroundEventLoop(bool scalable) {
} else {
loop = ev_loop_new(EVBACKEND_POLL);
}
+ if (loop == NULL) {
+ throw RuntimeException("Cannot create an event loop");
+ }
+
async = (ev_async *) malloc(sizeof(ev_async));
async->data = this;
ev_async_init(async, signalBackgroundEventLoopExit);

0 comments on commit caf5698

Please sign in to comment.