Loading src/event/kqueue.cpp +36 −18 Changes for src/event/kqueue.cpp: 36 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -132,6 +132,15 @@ namespace netplus { }; int getEventFlags(int pos) { // Check for error/hangs (EPOLLHUP/EPOLLERR) if (events & (EV_EOF | EV_ERROR)) { NetException e, e[NetException::Error] << "getEventFlags: som error";; } return _Events[pos].filter; } void setpollEvents(con* curcon,int filter,int events){ NetException except; struct kevent setevent = { 0 }; Loading @@ -151,7 +160,7 @@ namespace netplus { if(!pcon) return EventHandlerStatus::EVCON; return pcon->state; return -1; } int waitEventHandler() { Loading Loading @@ -351,42 +360,51 @@ namespace netplus { class EventWorker { public: EventWorker(int tid,ULONG_PTR args,EventWorkerArgs* eargs) { poll pollptr(eargs->ssocket,eargs->event,eargs->pollfd, eargs->timeout); int wait=0; // In EventWorker::EventWorker: while(RUNNING){ try { int wait=pollptr.waitEventHandler(); wait=pollptr.waitEventHandler(eargs->timeout); for(int i =0; i<wait; ++i){ try{ switch (pollptr.pollState(i)) { case pollapi::EventHandlerStatus::EVCON: int events = pollptr.pollState(i); // Check for listener socket (data.ptr is nullptr) if (events == pollapi::EventHandlerStatus::EVCON) { pollptr.ConnectEventHandler(i,tid,args); continue; case pollapi::EventHandlerStatus::EVIN: } events = pollptr.getEventFlags(i); // Prioritize read events (new data from client) if (events & EVFILT_READ) { pollptr.ReadEventHandler(i,tid,args); continue; case pollapi::EventHandlerStatus::EVOUT: } // Handle write events (ready to send data) if (events & EVFILT_WRITE) { pollptr.WriteEventHandler(i,tid,args); continue; default: } // FALLBACK/DEFAULT HANDLER NetException e; e[NetException::Error] << "EventWorker: no known event !"; e[NetException::Error] << "EventWorker: Unhandled epoll event type!"; throw e; } }catch(NetException& e){ switch(e.getErrorType()){ case NetException::Critical: throw e; case NetException::Note: continue; default: std::cerr << e.what() << std::endl; pollptr.CloseEventHandler(i,tid,args); continue; } if(e.getErrorType()==NetException::Critical) throw e; } } }catch (NetException& e) { std::cerr << e.what() << std::endl; } Loading src/socket.h +2 −4 Changes for src/socket.h: 2 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -133,10 +133,8 @@ namespace netplus { tcp(const netplus::tcp& ctcp) = delete; tcp& operator=(const tcp& socket) = delete; tcp(const std::string &uxsocket,int maxconnections, int sockopts); tcp(const std::string &addr,int port,int maxconnections, int sockopts); tcp(const std::string &uxsocket,int maxconnections,int sockopts=-1); tcp(const std::string &addr,int port,int maxconnections,int sockopts=-1); ~tcp(); #ifdef Windows void accept(LPFN_ACCEPTEX lpfnAcceptEx, std::unique_ptr<socket> &csock); Loading Loading
src/event/kqueue.cpp +36 −18 Changes for src/event/kqueue.cpp: 36 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -132,6 +132,15 @@ namespace netplus { }; int getEventFlags(int pos) { // Check for error/hangs (EPOLLHUP/EPOLLERR) if (events & (EV_EOF | EV_ERROR)) { NetException e, e[NetException::Error] << "getEventFlags: som error";; } return _Events[pos].filter; } void setpollEvents(con* curcon,int filter,int events){ NetException except; struct kevent setevent = { 0 }; Loading @@ -151,7 +160,7 @@ namespace netplus { if(!pcon) return EventHandlerStatus::EVCON; return pcon->state; return -1; } int waitEventHandler() { Loading Loading @@ -351,42 +360,51 @@ namespace netplus { class EventWorker { public: EventWorker(int tid,ULONG_PTR args,EventWorkerArgs* eargs) { poll pollptr(eargs->ssocket,eargs->event,eargs->pollfd, eargs->timeout); int wait=0; // In EventWorker::EventWorker: while(RUNNING){ try { int wait=pollptr.waitEventHandler(); wait=pollptr.waitEventHandler(eargs->timeout); for(int i =0; i<wait; ++i){ try{ switch (pollptr.pollState(i)) { case pollapi::EventHandlerStatus::EVCON: int events = pollptr.pollState(i); // Check for listener socket (data.ptr is nullptr) if (events == pollapi::EventHandlerStatus::EVCON) { pollptr.ConnectEventHandler(i,tid,args); continue; case pollapi::EventHandlerStatus::EVIN: } events = pollptr.getEventFlags(i); // Prioritize read events (new data from client) if (events & EVFILT_READ) { pollptr.ReadEventHandler(i,tid,args); continue; case pollapi::EventHandlerStatus::EVOUT: } // Handle write events (ready to send data) if (events & EVFILT_WRITE) { pollptr.WriteEventHandler(i,tid,args); continue; default: } // FALLBACK/DEFAULT HANDLER NetException e; e[NetException::Error] << "EventWorker: no known event !"; e[NetException::Error] << "EventWorker: Unhandled epoll event type!"; throw e; } }catch(NetException& e){ switch(e.getErrorType()){ case NetException::Critical: throw e; case NetException::Note: continue; default: std::cerr << e.what() << std::endl; pollptr.CloseEventHandler(i,tid,args); continue; } if(e.getErrorType()==NetException::Critical) throw e; } } }catch (NetException& e) { std::cerr << e.what() << std::endl; } Loading
src/socket.h +2 −4 Changes for src/socket.h: 2 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -133,10 +133,8 @@ namespace netplus { tcp(const netplus::tcp& ctcp) = delete; tcp& operator=(const tcp& socket) = delete; tcp(const std::string &uxsocket,int maxconnections, int sockopts); tcp(const std::string &addr,int port,int maxconnections, int sockopts); tcp(const std::string &uxsocket,int maxconnections,int sockopts=-1); tcp(const std::string &addr,int port,int maxconnections,int sockopts=-1); ~tcp(); #ifdef Windows void accept(LPFN_ACCEPTEX lpfnAcceptEx, std::unique_ptr<socket> &csock); Loading