diff options
author | Adam <Adam@anope.org> | 2011-11-08 17:29:16 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-11-08 17:29:16 -0500 |
commit | b5ff856f47d8e54d12c568462a06351633c29610 (patch) | |
tree | a4e2f96c59ee49aa5e6cacdfd30db6155151ad36 /src/socketengines | |
parent | 97b9055f92f21cd91af44a3d5dacce0024536cff (diff) |
Windows
Diffstat (limited to 'src/socketengines')
-rw-r--r-- | src/socketengines/pipeengine_pipe.cpp | 8 | ||||
-rw-r--r-- | src/socketengines/pipeengine_win32.cpp | 53 | ||||
-rw-r--r-- | src/socketengines/socketengine_select.cpp | 7 |
3 files changed, 10 insertions, 58 deletions
diff --git a/src/socketengines/pipeengine_pipe.cpp b/src/socketengines/pipeengine_pipe.cpp index f2fa0876a..7901931c8 100644 --- a/src/socketengines/pipeengine_pipe.cpp +++ b/src/socketengines/pipeengine_pipe.cpp @@ -10,7 +10,7 @@ Pipe::Pipe() : Socket(-1), WritePipe(-1) flags = fcntl(fds[1], F_GETFL, 0); fcntl(fds[1], F_SETFL, flags | O_NONBLOCK); - this->~Socket(); + this->~Pipe(); this->Sock = fds[0]; this->WritePipe = fds[1]; @@ -20,13 +20,14 @@ Pipe::Pipe() : Socket(-1), WritePipe(-1) Pipe::~Pipe() { - CloseSocket(this->WritePipe); + if (this->WritePipe >= 0) + close(this->WritePipe); } bool Pipe::ProcessRead() { char dummy[512]; - while (read(this->GetFD(), &dummy, 512) == 512); + while (read(this->GetFD(), dummy, 512) == 512); this->OnNotify(); return true; } @@ -40,4 +41,3 @@ void Pipe::Notify() void Pipe::OnNotify() { } - diff --git a/src/socketengines/pipeengine_win32.cpp b/src/socketengines/pipeengine_win32.cpp deleted file mode 100644 index f34472870..000000000 --- a/src/socketengines/pipeengine_win32.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "services.h" - -Pipe::Pipe() : Socket(-1) -{ - sockaddrs localhost; - - localhost.pton(AF_INET, "127.0.0.1"); - - int cfd = socket(AF_INET, SOCK_STREAM, 0), lfd = socket(AF_INET, SOCK_STREAM, 0); - if (cfd == -1) - throw CoreException("Error accepting new socket for Pipe"); - - if (bind(lfd, &localhost.sa, localhost.size()) == -1) - throw CoreException("Error accepting new socket for Pipe"); - if (listen(lfd, 1) == -1) - throw CoreException("Error accepting new socket for Pipe"); - - sockaddrs lfd_addr; - socklen_t sz = sizeof(lfd_addr); - getsockname(lfd, &lfd_addr.sa, &sz); - - if (connect(cfd, &lfd_addr.sa, lfd_addr.size())) - throw CoreException("Error accepting new socket for Pipe"); - CloseSocket(lfd); - - this->WritePipe = cfd; - - SocketEngine::AddSocket(this); -} - -Pipe::~Pipe() -{ - CloseSocket(this->WritePipe); -} - -bool Pipe::ProcessRead() -{ - char dummy[512]; - while (recv(this->GetFD(), dummy, 512, 0) == 512); - this->OnNotify(); - return true; -} - -void Pipe::Notify() -{ - const char dummy = '*'; - send(this->WritePipe, &dummy, 1, 0); -} - -void Pipe::OnNotify() -{ -} - diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp index 663cdd9ca..89a5c47c3 100644 --- a/src/socketengines/socketengine_select.cpp +++ b/src/socketengines/socketengine_select.cpp @@ -1,5 +1,10 @@ #include "module.h" +#ifdef _AIX +# undef FD_ZERO +# define FD_ZERO(p) memset((p), 0, sizeof(*(p))) +#endif /* _AIX */ + static int MaxFD; static unsigned FDCount; static fd_set ReadFDs; @@ -77,7 +82,7 @@ void SocketEngine::Process() */ if (FDCount == 0) { - sleep(Config->ReadTimeout); + sleep(tval.tv_sec); return; } #endif |