summaryrefslogtreecommitdiff
path: root/src/socketengines/socketengine_kqueue.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_kqueue.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_kqueue.cpp')
-rw-r--r--src/socketengines/socketengine_kqueue.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp
index 513677e44..a2bbd5afe 100644
--- a/src/socketengines/socketengine_kqueue.cpp
+++ b/src/socketengines/socketengine_kqueue.cpp
@@ -128,7 +128,11 @@ int KQueueEngine::DispatchEvents()
{
ts.tv_nsec = 0;
ts.tv_sec = 1;
+
int i = kevent(EngineHandle, NULL, 0, &ke_list[0], MAX_DESCRIPTORS, &ts);
+
+ TotalEvents += i;
+
for (int j = 0; j < i; j++)
{
if (ke_list[j].flags & EV_EOF)
@@ -138,6 +142,7 @@ int KQueueEngine::DispatchEvents()
* Unlike smelly epoll and select, where we have to getsockopt
* to get the error, this saves us time and cpu cycles. Go BSD!
*/
+ ErrorEvents++;
if (ref[ke_list[j].ident])
ref[ke_list[j].ident]->HandleEvent(EVENT_ERROR, ke_list[j].fflags);
continue;
@@ -150,11 +155,13 @@ int KQueueEngine::DispatchEvents()
struct kevent ke;
EV_SET(&ke, ke_list[j].ident, EVFILT_READ, EV_ADD, 0, 0, NULL);
kevent(EngineHandle, &ke, 1, 0, 0, NULL);
+ WriteEvents++;
if (ref[ke_list[j].ident])
ref[ke_list[j].ident]->HandleEvent(EVENT_WRITE);
}
else
{
+ ReadEvents++;
if (ref[ke_list[j].ident])
ref[ke_list[j].ident]->HandleEvent(EVENT_READ);
}