summaryrefslogtreecommitdiff
path: root/src/socketengines/socketengine_eventfd.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-10-01 21:01:49 -0400
committerAdam <Adam@anope.org>2010-10-01 21:01:49 -0400
commitd44f7971b129aa7ba80999f16f17b8c7499686e1 (patch)
treea86d08c3e641ed6b499b53b3bbb74e2a7f5b0dfb /src/socketengines/socketengine_eventfd.cpp
parent70056dd4689eeab4f7a9b31a921e0d7e40d5ed0d (diff)
Rewrote some of the socket code to allow m_ssl to be a service.
This allows modules (xmlrpc) to create and accept SSL connections. Also fixed unloading m_mysql at certain times and made the threading engine always work correctly on Windows.
Diffstat (limited to 'src/socketengines/socketengine_eventfd.cpp')
-rw-r--r--src/socketengines/socketengine_eventfd.cpp41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/socketengines/socketengine_eventfd.cpp b/src/socketengines/socketengine_eventfd.cpp
index a0efe5286..4e4016326 100644
--- a/src/socketengines/socketengine_eventfd.cpp
+++ b/src/socketengines/socketengine_eventfd.cpp
@@ -1,32 +1,47 @@
#include "services.h"
#include <sys/eventfd.h>
-int Pipe::RecvInternal(char *buf, size_t sz) const
+class PipeIO : public SocketIO
{
- static eventfd_t dummy;
- return !eventfd_read(this->Sock, &dummy);
-}
-
-int Pipe::SendInternal(const Anope::string &) const
-{
- return !eventfd_write(this->Sock, 1);
-}
-
-Pipe::Pipe() : Socket()
+ public:
+ /** Receive something from the buffer
+ * @param s The socket
+ * @param buf The buf to read to
+ * @param sz How much to read
+ * @return Number of bytes received
+ */
+ int Recv(Socket *s, char *buf, size_t sz) const
+ {
+ static eventfd_t dummy;
+ return !eventfd_read(s->GetFD(), &dummy);
+ }
+
+ /** Write something to the socket
+ * @param s The socket
+ * @param buf What to write
+ * @return Number of bytes written
+ */
+ int Send(Socket *s, const Anope::string &buf) const
+ {
+ return !eventfd_write(s->GetFD(), 1);
+ }
+} pipeSocketIO;
+
+Pipe::Pipe() : BufferedSocket()
{
+ this->IO = &pipeSocketIO;
this->Sock = eventfd(0, EFD_NONBLOCK);
if (this->Sock < 0)
throw CoreException(Anope::string("Could not create pipe: ") + Anope::LastError());
this->IPv6 = false;
- this->Type = SOCKTYPE_CLIENT;
SocketEngine->AddSocket(this);
}
bool Pipe::ProcessRead()
{
- this->RecvInternal(NULL, 0);
+ this->IO->Recv(this, NULL, 0);
return this->Read("");
}