From fd5f65b6f5c1848c7922c3820a90f6020abbabb1 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 25 Sep 2007 00:29:02 +0000 Subject: 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 --- src/socketengine_kqueue.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/socketengine_kqueue.cpp') 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); -- cgit v1.2.3