summaryrefslogtreecommitdiff
path: root/src/socketengines/socketengine_select.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-14 16:49:22 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-14 16:49:22 +0000
commitab4dee91de96555db158db91240ff91520318068 (patch)
tree1af96344a9c30466cec7e83ec9283efc9e8413a6 /src/socketengines/socketengine_select.cpp
parentf4ddd40badd2eb5181dadc1dcd59d7200738bf24 (diff)
Keep count of the number of events in total, and seperate read, write and error event counters. We can use this for monitoring of heavy socket engine activity, e.g. a 'stuck' eventhandler
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8933 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socketengines/socketengine_select.cpp')
-rw-r--r--src/socketengines/socketengine_select.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp
index b7427612e..cc7232b99 100644
--- a/src/socketengines/socketengine_select.cpp
+++ b/src/socketengines/socketengine_select.cpp
@@ -132,27 +132,35 @@ int SelectEngine::DispatchEvents()
{
if (FD_ISSET (ev[i]->GetFd(), &errfdset))
{
- if (ev[i])
- {
- if (getsockopt(ev[i]->GetFd(), SOL_SOCKET, SO_ERROR, (char*)&errcode, &codesize) < 0)
- errcode = errno;
+ ErrorEvents++;
+
+ if (getsockopt(ev[i]->GetFd(), SOL_SOCKET, SO_ERROR, (char*)&errcode, &codesize) < 0)
+ errcode = errno;
+
+ ev[i]->HandleEvent(EVENT_ERROR, errcode);
- ev[i]->HandleEvent(EVENT_ERROR, errcode);
- }
continue;
}
- if (ev[i])
+ else
{
if (writeable[ev[i]->GetFd()])
{
+ WriteEvents++;
writeable[ev[i]->GetFd()] = false;
- if (ev[i])
- ev[i]->HandleEvent(EVENT_WRITE);
+ ev[i]->HandleEvent(EVENT_WRITE);
}
else
{
- if (ev[i])
- ev[i]->HandleEvent(ev[i]->Readable() ? EVENT_READ : EVENT_WRITE);
+ if (ev[i]->Readable())
+ {
+ ReadEvents++;
+ ev[i]->HandleEvent(EVENT_READ);
+ }
+ else
+ {
+ WriteEvents++;
+ ev[i]->HandleEvent(EVENT_WRITE);
+ }
}
}
}