X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsocketengine.cpp;h=300a08bccca8c4c3fd2fcde7bfe020064e157a13;hb=c6a3d4bafc70dc9bd99b9da37c4b12a5324d4e0f;hp=90d25e0604eaea1d5e392c364487d620e583a423;hpb=a3802dee4bdfcf3dc11df09c59e6ed1912fbadd9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/socketengine.cpp b/src/socketengine.cpp index 90d25e060..300a08bcc 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -11,12 +11,18 @@ * --------------------------------------------------- */ -/* $Core: libIRCDsocketengine */ +/* $Core */ /********* DEFAULTS **********/ + /* $ExtraSources: socketengines/socketengine_select.cpp */ /* $ExtraObjects: socketengine_select.o */ +/* $If: USE_POLL */ +/* $ExtraSources: socketengines/socketengine_poll.cpp */ +/* $ExtraObjects: socketengine_poll.o */ +/* $EndIf */ + /* $If: USE_KQUEUE */ /* $ExtraSources: socketengines/socketengine_kqueue.cpp */ /* $ExtraObjects: socketengine_kqueue.o */ @@ -35,6 +41,34 @@ #include "inspircd.h" #include "socketengine.h" +EventHandler::EventHandler() +{ + this->IOHook = NULL; +} + +bool EventHandler::AddIOHook(Module *IOHooker) +{ + if (this->IOHook) + return false; + + this->IOHook = IOHooker; + return true; +} + +bool EventHandler::DelIOHook() +{ + if (!this->IOHook) + return false; + + this->IOHook = NULL; + return true; +} + +Module *EventHandler::GetIOHook() +{ + return this->IOHook; +} + int EventHandler::GetFd() { return this->fd; @@ -62,7 +96,7 @@ void SocketEngine::WantWrite(EventHandler* eh) SocketEngine::SocketEngine(InspIRCd* Instance) : ServerInstance(Instance) { TotalEvents = WriteEvents = ReadEvents = ErrorEvents = 0; - lastempty = time(NULL); + lastempty = ServerInstance->Time(); indata = outdata = 0; } @@ -229,9 +263,9 @@ void SocketEngine::RecoverFromFork() void SocketEngine::UpdateStats(size_t len_in, size_t len_out) { - if (lastempty + 1 > time(NULL)) + if (lastempty != ServerInstance->Time()) { - lastempty = time(NULL); + lastempty = ServerInstance->Time(); indata = outdata = 0; } indata += len_in; @@ -240,9 +274,10 @@ void SocketEngine::UpdateStats(size_t len_in, size_t len_out) void SocketEngine::GetStats(float &kbitpersec_in, float &kbitpersec_out, float &kbitpersec_total) { + UpdateStats(0, 0); /* Forces emptying of the values if its been more than a second */ float in_kbit = indata * 8; float out_kbit = outdata * 8; - kbitpersec_total = ((in_kbit + out_kbit)) / 1024); + kbitpersec_total = ((in_kbit + out_kbit) / 1024); kbitpersec_in = in_kbit / 1024; kbitpersec_out = out_kbit / 1024; }