summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-03-02 01:48:06 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-03-02 01:48:06 +0000
commit5af0e15f15f0b09643dcdf6da3d9eb2349d16422 (patch)
treec714d992179e35a300cefd4f9fff8b3a352cc32e
parent2561ede5059f0e3340466a302b404efd2381c77f (diff)
Don't send events for removed FDs when both read and write are ready
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12582 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/socketengines/socketengine_kqueue.cpp4
-rw-r--r--src/socketengines/socketengine_poll.cpp15
-rw-r--r--src/socketengines/socketengine_ports.cpp14
-rw-r--r--src/socketengines/socketengine_select.cpp2
4 files changed, 11 insertions, 24 deletions
diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp
index 63a877238..6f329357d 100644
--- a/src/socketengines/socketengine_kqueue.cpp
+++ b/src/socketengines/socketengine_kqueue.cpp
@@ -230,6 +230,10 @@ int KQueueEngine::DispatchEvents()
const int bits_to_clr = FD_WANT_SINGLE_WRITE | FD_WANT_FAST_WRITE | FD_WRITE_WILL_BLOCK;
SetEventMask(eh, eh->GetEventMask() & ~bits_to_clr);
eh->HandleEvent(EVENT_WRITE);
+
+ if (eh != ref[ke_list[j].ident];
+ // whoops, deleted out from under us
+ continue;
}
if (ke_list[j].filter == EVFILT_READ)
{
diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp
index 93463aea7..a1e0b815a 100644
--- a/src/socketengines/socketengine_poll.cpp
+++ b/src/socketengines/socketengine_poll.cpp
@@ -13,18 +13,6 @@
#include "inspircd.h"
#include "exitcodes.h"
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
#ifndef __SOCKETENGINE_POLL__
#define __SOCKETENGINE_POLL__
@@ -269,6 +257,9 @@ int PollEngine::DispatchEvents()
{
SetEventMask(eh, eh->GetEventMask() & ~FD_READ_WILL_BLOCK);
eh->HandleEvent(EVENT_READ);
+ if (eh != ref[index])
+ // whoops, deleted out from under us
+ continue;
}
if (events[index].revents & POLLOUT)
diff --git a/src/socketengines/socketengine_ports.cpp b/src/socketengines/socketengine_ports.cpp
index 23a3c3a45..5642a7223 100644
--- a/src/socketengines/socketengine_ports.cpp
+++ b/src/socketengines/socketengine_ports.cpp
@@ -14,18 +14,6 @@
#include "inspircd.h"
#include "exitcodes.h"
#include <port.h>
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
#ifndef __SOCKETENGINE_PORTS__
#define __SOCKETENGINE_PORTS__
@@ -197,6 +185,8 @@ int PortsEngine::DispatchEvents()
{
ReadEvents++;
eh->HandleEvent(EVENT_READ);
+ if (eh != ref[fd])
+ continue;
}
if (events[i].portev_events & POLLWRNORM)
{
diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp
index 795e844e6..3c33eb474 100644
--- a/src/socketengines/socketengine_select.cpp
+++ b/src/socketengines/socketengine_select.cpp
@@ -151,6 +151,8 @@ int SelectEngine::DispatchEvents()
ReadEvents++;
SetEventMask(ev, ev->GetEventMask() & ~FD_READ_WILL_BLOCK);
ev->HandleEvent(EVENT_READ);
+ if (ev != ref[i])
+ continue;
}
if (FD_ISSET (i, &wfdset))
{