#include "threadengines/threadengine_pthread.h"
#include <pthread.h>
#include <signal.h>
+#include <fcntl.h>
ThreadEngine::ThreadEngine(InspIRCd* Instance)
{
sigaddset(&set, SIGPIPE);
pthread_sigmask(SIG_BLOCK, &set, NULL);
- Thread* pt = reinterpret_cast<Thread*>(parameter);
+ Thread* pt = static_cast<Thread*>(parameter);
pt->Run();
return parameter;
}
pthread_join(pthread_id, NULL);
}
-#if 0
-/* TODO this is a linux-specific syscall that allows signals to be
- * sent using a single file descriptor, rather than 2 for a pipe.
- * Requires glibc 2.8, kernel 2.6.22+
- */
+#ifdef HAS_EVENTFD
#include <sys/eventfd.h>
class ThreadSignalSocket : public BufferedSocket
SocketThread::SocketThread(InspIRCd* SI)
{
- int fd = eventfd(0, 0); // TODO nonblock
+ int fd = eventfd(0, O_NONBLOCK);
if (fd < 0)
throw new CoreException("Could not create pipe " + std::string(strerror(errno)));
signal.sock = new ThreadSignalSocket(this, SI, fd);
void Notify()
{
char dummy = '*';
- send(send_fd, &dummy, 1, 0);
+ write(send_fd, &dummy, 1);
}
virtual bool OnDataReady()
{
char data;
- if (ServerInstance->SE->Recv(this, &data, 1, 0) <= 0)
+ if (read(this->fd, &data, 1) <= 0)
return false;
parent->OnNotify();
return true;
SocketThread::~SocketThread()
{
- delete signal.sock;
}