diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-09-25 00:29:02 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-09-25 00:29:02 +0000 |
commit | fd5f65b6f5c1848c7922c3820a90f6020abbabb1 (patch) | |
tree | 58146a91f73a175b884bad95ca2942d397012206 /src/socketengine_kqueue.cpp | |
parent | edf061fc6a7259f84a4e3be6f43c9e0601b3b39d (diff) |
Fix for bug #407, set ref[fd] AFTER some checks that may return false and leave the socket engine in an undefined state
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8077 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socketengine_kqueue.cpp')
-rw-r--r-- | src/socketengine_kqueue.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/socketengine_kqueue.cpp b/src/socketengine_kqueue.cpp index e33f9f772..50f6242e2 100644 --- a/src/socketengine_kqueue.cpp +++ b/src/socketengine_kqueue.cpp @@ -61,15 +61,16 @@ bool KQueueEngine::AddFd(EventHandler* eh) if (ref[fd]) return false; - ref[fd] = eh; - struct kevent ke; EV_SET(&ke, fd, eh->Readable() ? EVFILT_READ : EVFILT_WRITE, EV_ADD, 0, 0, NULL); int i = kevent(EngineHandle, &ke, 1, 0, 0, NULL); if (i == -1) + { return false; + } + ref[fd] = eh; CurrentSetSize++; ServerInstance->Log(DEBUG,"New file descriptor: %d", fd); |