summaryrefslogtreecommitdiff
path: root/src/threadengines
diff options
context:
space:
mode:
authorDaniel De Graaf <danieldg@inspircd.org>2010-06-19 20:58:57 -0400
committerDaniel De Graaf <danieldg@inspircd.org>2010-08-04 14:45:40 -0400
commit33efd30b33511dc6aa7b598e269b88de7441e7a9 (patch)
tree8ef77e3aaf1f83c3683686b745b727083795e1f3 /src/threadengines
parent6ae79027cf27507f0c637ced1c645facaec8bacb (diff)
Change ThreadSignalSocket to EventHandler to avoid calling recv() on an eventfd, which does not work
Diffstat (limited to 'src/threadengines')
-rw-r--r--src/threadengines/threadengine_pthread.cpp57
1 files changed, 36 insertions, 21 deletions
diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp
index f2640b5ae..29a4b1a96 100644
--- a/src/threadengines/threadengine_pthread.cpp
+++ b/src/threadengines/threadengine_pthread.cpp
@@ -61,11 +61,15 @@ void ThreadData::FreeThread(Thread* thread)
#ifdef HAS_EVENTFD
#include <sys/eventfd.h>
-class ThreadSignalSocket : public BufferedSocket
+class ThreadSignalSocket : public EventHandler
{
SocketThread* parent;
public:
- ThreadSignalSocket(SocketThread* p, int newfd) : BufferedSocket(newfd), parent(p) {}
+ ThreadSignalSocket(SocketThread* p, int newfd) : parent(p)
+ {
+ SetFd(newfd);
+ ServerInstance->SE->AddFd(this, FD_WANT_FAST_READ | FD_WANT_NO_WRITE);
+ }
~ThreadSignalSocket()
{
@@ -76,15 +80,18 @@ class ThreadSignalSocket : public BufferedSocket
eventfd_write(fd, 1);
}
- void OnDataReady()
- {
- recvq.clear();
- parent->OnNotify();
- }
-
- void OnError(BufferedSocketError)
+ void HandleEvent(EventType et, int errornum)
{
- ServerInstance->GlobalCulls.AddItem(this);
+ if (et == EVENT_READ)
+ {
+ eventfd_t dummy;
+ eventfd_read(fd, &dummy);
+ parent->OnNotify();
+ }
+ else
+ {
+ ServerInstance->GlobalCulls.AddItem(this);
+ }
}
};
@@ -97,13 +104,18 @@ SocketThread::SocketThread()
}
#else
-class ThreadSignalSocket : public BufferedSocket
+class ThreadSignalSocket : public EventHandler
{
SocketThread* parent;
int send_fd;
public:
ThreadSignalSocket(SocketThread* p, int recvfd, int sendfd) :
- BufferedSocket(recvfd), parent(p), send_fd(sendfd) {}
+ parent(p), send_fd(sendfd)
+ {
+ SetFd(recvfd);
+ ServerInstance->SE->NonBlocking(fd);
+ ServerInstance->SE->AddFd(this, FD_WANT_FAST_READ | FD_WANT_NO_WRITE);
+ }
~ThreadSignalSocket()
{
@@ -112,19 +124,22 @@ class ThreadSignalSocket : public BufferedSocket
void Notify()
{
- char dummy = '*';
+ static const char dummy = '*';
write(send_fd, &dummy, 1);
}
- void OnDataReady()
- {
- recvq.clear();
- parent->OnNotify();
- }
-
- void OnError(BufferedSocketError)
+ void HandleEvent(EventType et, int errornum)
{
- ServerInstance->GlobalCulls.AddItem(this);
+ if (et == EVENT_READ)
+ {
+ char dummy[128];
+ read(fd, dummy, 128);
+ parent->OnNotify();
+ }
+ else
+ {
+ ServerInstance->GlobalCulls.AddItem(this);
+ }
}
};