Loading src/eventapi.h +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ namespace netplus { int _pollFD; struct poll_event *_Events; socket *_ServerSocket; std::atomic<bool> _ConLock; std::atomic<bool> _WaitLock; }; class event : public poll { Loading src/linux/event.cpp +9 −15 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ namespace netplus { poll::poll(socket* serversocket) { _ServerSocket = serversocket; _ConLock=false; _WaitLock=false; }; poll::~poll() { Loading Loading @@ -110,7 +110,15 @@ namespace netplus { } unsigned int poll::waitEventHandler() { bool expected = false; if(!_WaitLock.compare_exchange_strong(expected,true)) return 0; int ret = epoll_wait(_pollFD, (struct epoll_event*)_Events, _ServerSocket->getMaxconnections(), -1); _WaitLock.store(false); if (ret <0 ) { NetException exception; exception[NetException::Error] << "waitEventHandler: epoll wait failure"; Loading @@ -122,10 +130,6 @@ namespace netplus { void poll::ConnectEventHandler(int pos) { NetException exception; con *ccon = (con*)_Events[pos].data.ptr; bool expected = false; if(!_ConLock.compare_exchange_strong(expected,true)) return; try { ccon = new con(this); Loading Loading @@ -162,7 +166,6 @@ namespace netplus { throw e; } } _ConLock.store(false); }; void poll::ReadEventHandler(int pos) { Loading @@ -186,11 +189,6 @@ namespace netplus { void poll::WriteEventHandler(int pos) { con *wcon = (con*)_Events[pos].data.ptr; if (!wcon) { NetException exp; exp[NetException::Error] << "WriteEvent: No valied Connection!"; throw exp; } try { if(!wcon->getSendData()){ NetException exp; Loading @@ -213,10 +211,6 @@ namespace netplus { void poll::CloseEventHandler(int pos) { NetException except; con *delcon = (con*)_Events[pos].data.ptr; if(!delcon){ except[NetException::Error] << "CloseEvent connection not exists!"; throw except; } if(delcon->csock){ int ect = epoll_ctl(_pollFD, EPOLL_CTL_DEL, Loading Loading
src/eventapi.h +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ namespace netplus { int _pollFD; struct poll_event *_Events; socket *_ServerSocket; std::atomic<bool> _ConLock; std::atomic<bool> _WaitLock; }; class event : public poll { Loading
src/linux/event.cpp +9 −15 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ namespace netplus { poll::poll(socket* serversocket) { _ServerSocket = serversocket; _ConLock=false; _WaitLock=false; }; poll::~poll() { Loading Loading @@ -110,7 +110,15 @@ namespace netplus { } unsigned int poll::waitEventHandler() { bool expected = false; if(!_WaitLock.compare_exchange_strong(expected,true)) return 0; int ret = epoll_wait(_pollFD, (struct epoll_event*)_Events, _ServerSocket->getMaxconnections(), -1); _WaitLock.store(false); if (ret <0 ) { NetException exception; exception[NetException::Error] << "waitEventHandler: epoll wait failure"; Loading @@ -122,10 +130,6 @@ namespace netplus { void poll::ConnectEventHandler(int pos) { NetException exception; con *ccon = (con*)_Events[pos].data.ptr; bool expected = false; if(!_ConLock.compare_exchange_strong(expected,true)) return; try { ccon = new con(this); Loading Loading @@ -162,7 +166,6 @@ namespace netplus { throw e; } } _ConLock.store(false); }; void poll::ReadEventHandler(int pos) { Loading @@ -186,11 +189,6 @@ namespace netplus { void poll::WriteEventHandler(int pos) { con *wcon = (con*)_Events[pos].data.ptr; if (!wcon) { NetException exp; exp[NetException::Error] << "WriteEvent: No valied Connection!"; throw exp; } try { if(!wcon->getSendData()){ NetException exp; Loading @@ -213,10 +211,6 @@ namespace netplus { void poll::CloseEventHandler(int pos) { NetException except; con *delcon = (con*)_Events[pos].data.ptr; if(!delcon){ except[NetException::Error] << "CloseEvent connection not exists!"; throw except; } if(delcon->csock){ int ect = epoll_ctl(_pollFD, EPOLL_CTL_DEL, Loading