diff options
Diffstat (limited to 'src/socketengine_select.cpp')
-rw-r--r-- | src/socketengine_select.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/socketengine_select.cpp b/src/socketengine_select.cpp index 4e79dc19b..ec242b76d 100644 --- a/src/socketengine_select.cpp +++ b/src/socketengine_select.cpp @@ -35,8 +35,9 @@ SelectEngine::~SelectEngine() ServerInstance->Log(DEBUG,"SelectEngine::~SelectEngine()"); } -bool SelectEngine::AddFd(int fd, bool readable, char type) +bool SelectEngine::AddFd(EventHandler* eh) { + int fd = eh->GetFd(); if ((fd < 0) || (fd > MAX_DESCRIPTORS)) { ServerInstance->Log(DEFAULT,"ERROR: FD of %d added above max of %d",fd,MAX_DESCRIPTORS); @@ -53,20 +54,17 @@ bool SelectEngine::AddFd(int fd, bool readable, char type) if (ref[fd]) return false; - ref[fd] = type; - if (readable) - { - ServerInstance->Log(DEBUG,"Set readbit"); - ref[fd] |= X_READBIT; - } + ref[fd] = eh; ServerInstance->Log(DEBUG,"Add socket %d",fd); CurrentSetSize++; return true; } -bool SelectEngine::DelFd(int fd) +bool SelectEngine::DelFd(EventHandler* eh) { + int fd = eh->GetFd(); + ServerInstance->Log(DEBUG,"SelectEngine::DelFd(%d)",fd); if ((fd < 0) || (fd > MAX_DESCRIPTORS)) @@ -80,7 +78,7 @@ bool SelectEngine::DelFd(int fd) } CurrentSetSize--; - ref[fd] = 0; + ref[fd] = NULL; return true; } @@ -94,7 +92,7 @@ int SelectEngine::GetRemainingFds() return FD_SETSIZE - CurrentSetSize; } -int SelectEngine::Wait(int* fdlist) +int SelectEngine::Wait(EventHandler** fdlist) { int result = 0; @@ -104,7 +102,7 @@ int SelectEngine::Wait(int* fdlist) int sresult; for (std::map<int,int>::iterator a = fds.begin(); a != fds.end(); a++) { - if (ref[a->second] & X_READBIT) + if (ref[a->second]->Readable()) { FD_SET (a->second, &rfdset); } @@ -122,7 +120,7 @@ int SelectEngine::Wait(int* fdlist) for (std::map<int,int>::iterator a = fds.begin(); a != fds.end(); a++) { if ((FD_ISSET (a->second, &rfdset)) || (FD_ISSET (a->second, &wfdset))) - fdlist[result++] = a->second; + fdlist[result++] = ref[a->second]; } } |