summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/socketengine_select.h2
-rw-r--r--src/socketengine_epoll.cpp2
-rw-r--r--src/socketengine_select.cpp13
3 files changed, 14 insertions, 3 deletions
diff --git a/include/socketengine_select.h b/include/socketengine_select.h
index 053ebc8c6..847e044a1 100644
--- a/include/socketengine_select.h
+++ b/include/socketengine_select.h
@@ -41,7 +41,7 @@ private:
bool writeable[MAX_DESCRIPTORS];
/** The read set and write set, populated before each call to select().
*/
- fd_set wfdset, rfdset;
+ fd_set wfdset, rfdset, errfdset;
public:
/** Create a new SelectEngine
* @param Instance The creator of this object
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()])
{