From ab4dee91de96555db158db91240ff91520318068 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 14 Feb 2008 16:49:22 +0000 Subject: 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 --- src/socketengines/socketengine_select.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/socketengines/socketengine_select.cpp') 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); + } } } } -- cgit v1.2.3