diff options
author | Robin Burchell <robin+git@viroteck.net> | 2017-03-22 17:59:08 +0100 |
---|---|---|
committer | Robin Burchell <robin+git@viroteck.net> | 2017-07-11 14:22:02 +0200 |
commit | 8e8b0719bf58e2d875c06698f86377189da87e16 (patch) | |
tree | 645d98c5eb05ebe8ed4f1aebd9d060d296e41b3b /src/socketengines/socketengine_select.cpp | |
parent | e97ee390cf1a3f5e897aed85d62e29a34c4632f9 (diff) |
Improve and centralize socket engine event counters.
The write counters were close to useless because they were only
incremented on a write "event" which is only triggered when writing
would block.
Read handling was a little more useful in that all reads must happen
through the socket engine, so these were happening at the correct time,
but we can clean this up by doing it in the SE itself rather than each
platform port.
This means that both read and write events are now easily and usefully
defined as "a syscall of either read or write was attempted".
We also count empty read and write events as being an event, because
they still were an attempt to poll a socket in some way. This may help
to identify "bad" code which is repeatedly trying to read a socket for
some reason.
Lastly, we check for failed read/write calls, and log them as an error
event. A lot of the time, this is how sockets are determined as being
disconnected (ie. at read/write time).
While we're at it, split Update() in two to make the calls more
self-describing. This has no real impact since only one call is made at
a time anyway.
Diffstat (limited to 'src/socketengines/socketengine_select.cpp')
-rw-r--r-- | src/socketengines/socketengine_select.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp index 6dfbae88e..42f634db1 100644 --- a/src/socketengines/socketengine_select.cpp +++ b/src/socketengines/socketengine_select.cpp @@ -147,7 +147,6 @@ int SocketEngine::DispatchEvents() if (has_read) { - stats.ReadEvents++; ev->SetEventMask(ev->GetEventMask() & ~FD_READ_WILL_BLOCK); ev->OnEventHandlerRead(); if (ev != GetRef(i)) @@ -156,7 +155,6 @@ int SocketEngine::DispatchEvents() if (has_write) { - stats.WriteEvents++; int newmask = (ev->GetEventMask() & ~(FD_WRITE_WILL_BLOCK | FD_WANT_SINGLE_WRITE)); SocketEngine::OnSetEvent(ev, ev->GetEventMask(), newmask); ev->SetEventMask(newmask); |