diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/socketengine_epoll.cpp | 2 | ||||
-rw-r--r-- | src/socketengine_select.cpp | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/socketengine_epoll.cpp b/src/socketengine_epoll.cpp index 618f30592..c1aab07d8 100644 --- a/src/socketengine_epoll.cpp +++ b/src/socketengine_epoll.cpp @@ -138,6 +138,7 @@ int EPollEngine::DispatchEvents() ServerInstance->Log(DEBUG,"Handle %s event on fd %d",events[j].events & EPOLLOUT ? "write" : "read", events[j].data.fd); if (events[j].events & EPOLLHUP) { + ServerInstance->Log(DEBUG,"Handle error event on fd %d", events[j].data.fd); ref[events[j].data.fd]->HandleEvent(EVENT_ERROR, 0); continue; } @@ -146,6 +147,7 @@ int EPollEngine::DispatchEvents() /* Get error number */ if (getsockopt(events[j].data.fd, SOL_SOCKET, SO_ERROR, &errcode, &codesize) < 0) errcode = errno; + ServerInstance->Log(DEBUG,"Handle error event on fd %d: %s", events[j].data.fd, strerror(errcode)); ref[events[j].data.fd]->HandleEvent(EVENT_ERROR, errcode); continue; } diff --git a/src/socketengine_select.cpp b/src/socketengine_select.cpp index cdd1bdc3c..a26c28e51 100644 --- a/src/socketengine_select.cpp +++ b/src/socketengine_select.cpp @@ -103,6 +103,7 @@ int SelectEngine::DispatchEvents() FD_ZERO(&wfdset); FD_ZERO(&rfdset); + FD_ZERO(&errfdset); for (std::map<int,int>::iterator a = fds.begin(); a != fds.end(); a++) { @@ -112,15 +113,17 @@ int SelectEngine::DispatchEvents() FD_SET (a->second, &wfdset); if (writeable[a->second]) FD_SET (a->second, &wfdset); + + FD_SET (a->second, &errfdset); } tval.tv_sec = 0; tval.tv_usec = 50L; - sresult = select(FD_SETSIZE, &rfdset, &wfdset, NULL, &tval); + sresult = select(FD_SETSIZE, &rfdset, &wfdset, &errfdset, &tval); if (sresult > 0) { for (std::map<int,int>::iterator a = fds.begin(); a != fds.end(); a++) { - if ((FD_ISSET (a->second, &rfdset)) || (FD_ISSET (a->second, &wfdset))) + if ((FD_ISSET (a->second, &rfdset)) || (FD_ISSET (a->second, &wfdset)) || FD_ISSET (a->second, &errfdset)) { ev[result++] = ref[a->second]; } @@ -136,6 +139,12 @@ int SelectEngine::DispatchEvents() { if (ev[i]) { + if (FD_ISSET (a->second, &errfdset)) + { + if (ev[i]) + ev[i]->HandleEvent(EVENT_ERROR, 0); + continue; + } ServerInstance->Log(DEBUG,"Handle %s event on fd %d",writeable[ev[i]->GetFd()] || !ev[i]->Readable() ? "write" : "read", ev[i]->GetFd()); if (writeable[ev[i]->GetFd()]) { |