X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsocketengine_ports.cpp;h=352b730620fbc7d300eaadbe9e16eeffaef4189c;hb=19157777c5f977fddbcfdc8cdad78e12bf0d6bbb;hp=f036a8e10ef1c03c4196ce6088148ca05c881e2e;hpb=772dc6c47406b0ca6be5e49914dd739c8d580bd5;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/socketengine_ports.cpp b/src/socketengine_ports.cpp index f036a8e10..352b73062 100644 --- a/src/socketengine_ports.cpp +++ b/src/socketengine_ports.cpp @@ -13,7 +13,7 @@ #include "inspircd.h" #include "exitcodes.h" -#include +#include #include "socketengine_ports.h" PortsEngine::PortsEngine(InspIRCd* Instance) : SocketEngine(Instance) @@ -26,14 +26,14 @@ PortsEngine::PortsEngine(InspIRCd* Instance) : SocketEngine(Instance) ServerInstance->Log(SPARSE,"ERROR: This is a fatal error, exiting now."); printf("ERROR: Could not initialize socket engine: %s\n", strerror(errno)); printf("ERROR: This is a fatal error, exiting now.\n"); - InspIRCd::Exit(EXIT_STATUS_SOCKETENGINE); + ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE); } CurrentSetSize = 0; } PortsEngine::~PortsEngine() { - close(EngineHandle); + this->Close(EngineHandle); } bool PortsEngine::AddFd(EventHandler* eh) @@ -104,10 +104,17 @@ int PortsEngine::DispatchEvents() { switch (this->events[i].portev_source) { - case PORT_SOURCE_FD: - int fd = this->events[i].portev_object; - ref[fd]->HandleEvent((this->events[i].portev_events & POLLRDNORM) ? EVENT_READ : EVENT_WRITE); - default: + case PORT_SOURCE_FD: + { + int fd = this->events[i].portev_object; + if (ref[fd]) + { + // reinsert port for next time around + port_associate(EngineHandle, PORT_SOURCE_FD, fd, POLLRDNORM, ref[fd]); + ref[fd]->HandleEvent((this->events[i].portev_events & POLLRDNORM) ? EVENT_READ : EVENT_WRITE); + } + } + default: break; } }