Loading src/event/epoll.cpp +9 −10 Changes for src/event/epoll.cpp: 9 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -170,9 +170,9 @@ namespace netplus { void ConnectEventHandler(int pos,const int tid,ULONG_PTR args) { NetException exception; std::unique_ptr<con> ccon; con *ccon; evconnection->CreateConnection(ccon); evconnection->CreateConnection(&ccon); if(_ServerSocket->_Type==sockettype::TCP){ ccon->csock=std::make_unique<tcp>(-1); Loading @@ -194,10 +194,9 @@ namespace netplus { struct epoll_event setevent { 0 }; setevent.events = EPOLLIN | EPOLLONESHOT | EPOLLET; con *oldptr=ccon.release(); setevent.data.ptr = oldptr; setevent.data.ptr = ccon; int estate = epoll_ctl(_pollFD, EPOLL_CTL_ADD,oldptr->csock->fd(), &setevent); int estate = epoll_ctl(_pollFD, EPOLL_CTL_ADD,ccon->csock->fd(), &setevent); if ( estate < 0 ) { char errstr[255]; Loading @@ -206,7 +205,7 @@ namespace netplus { throw exception; } evconnection ->ConnectEvent(*oldptr,tid,args); evconnection ->ConnectEvent(*ccon,tid,args); }; void ReadEventHandler(int pos,const int tid,ULONG_PTR args) { Loading Loading @@ -298,7 +297,7 @@ namespace netplus { void CloseEventHandler(int pos,const int tid,ULONG_PTR args) { std::lock_guard<std::mutex> global_lock(CLOSE_HANDLER_MUTEX); if (!_Events[pos].data.ptr) { if (!_Events || !_Events[pos].data.ptr) { return; } Loading Loading @@ -326,7 +325,7 @@ void CloseEventHandler(int pos,const int tid,ULONG_PTR args) { _Events[pos].data.ptr = nullptr; } delete ccon; evconnection->DeleteConnection(ccon); } private: Loading Loading @@ -419,9 +418,9 @@ void CloseEventHandler(int pos,const int tid,ULONG_PTR args) { std::cerr << e.what() << std::endl; } } //secure all sockets closed for(int i =0; i<eargs->ssocket->getMaxconnections(); ++i){ pollptr.CloseEventHandler(i,tid,args); pollptr.CloseEventHandler(i,tid,0); } } Loading src/eventapi.h +2 −1 Changes for src/eventapi.h: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ namespace netplus { virtual void ConnectEvent(con &curcon,const int tid, ULONG_PTR args)=0; virtual void DisconnectEvent(con &curcon,const int tid, ULONG_PTR args)=0; /*memory allocation*/ virtual void CreateConnection(std::unique_ptr<con> &res)=0; virtual void CreateConnection(con **res)=0; virtual void DeleteConnection(con *res)=0; protected: eventapi(){}; }; Loading Loading
src/event/epoll.cpp +9 −10 Changes for src/event/epoll.cpp: 9 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -170,9 +170,9 @@ namespace netplus { void ConnectEventHandler(int pos,const int tid,ULONG_PTR args) { NetException exception; std::unique_ptr<con> ccon; con *ccon; evconnection->CreateConnection(ccon); evconnection->CreateConnection(&ccon); if(_ServerSocket->_Type==sockettype::TCP){ ccon->csock=std::make_unique<tcp>(-1); Loading @@ -194,10 +194,9 @@ namespace netplus { struct epoll_event setevent { 0 }; setevent.events = EPOLLIN | EPOLLONESHOT | EPOLLET; con *oldptr=ccon.release(); setevent.data.ptr = oldptr; setevent.data.ptr = ccon; int estate = epoll_ctl(_pollFD, EPOLL_CTL_ADD,oldptr->csock->fd(), &setevent); int estate = epoll_ctl(_pollFD, EPOLL_CTL_ADD,ccon->csock->fd(), &setevent); if ( estate < 0 ) { char errstr[255]; Loading @@ -206,7 +205,7 @@ namespace netplus { throw exception; } evconnection ->ConnectEvent(*oldptr,tid,args); evconnection ->ConnectEvent(*ccon,tid,args); }; void ReadEventHandler(int pos,const int tid,ULONG_PTR args) { Loading Loading @@ -298,7 +297,7 @@ namespace netplus { void CloseEventHandler(int pos,const int tid,ULONG_PTR args) { std::lock_guard<std::mutex> global_lock(CLOSE_HANDLER_MUTEX); if (!_Events[pos].data.ptr) { if (!_Events || !_Events[pos].data.ptr) { return; } Loading Loading @@ -326,7 +325,7 @@ void CloseEventHandler(int pos,const int tid,ULONG_PTR args) { _Events[pos].data.ptr = nullptr; } delete ccon; evconnection->DeleteConnection(ccon); } private: Loading Loading @@ -419,9 +418,9 @@ void CloseEventHandler(int pos,const int tid,ULONG_PTR args) { std::cerr << e.what() << std::endl; } } //secure all sockets closed for(int i =0; i<eargs->ssocket->getMaxconnections(); ++i){ pollptr.CloseEventHandler(i,tid,args); pollptr.CloseEventHandler(i,tid,0); } } Loading
src/eventapi.h +2 −1 Changes for src/eventapi.h: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ namespace netplus { virtual void ConnectEvent(con &curcon,const int tid, ULONG_PTR args)=0; virtual void DisconnectEvent(con &curcon,const int tid, ULONG_PTR args)=0; /*memory allocation*/ virtual void CreateConnection(std::unique_ptr<con> &res)=0; virtual void CreateConnection(con **res)=0; virtual void DeleteConnection(con *res)=0; protected: eventapi(){}; }; Loading