Loading src/event/epoll.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -325,12 +325,12 @@ namespace netplus { class EventWorker { public: EventWorker(int tid,EventWorkerArgs* args) { poll pollptr(args->ssocket,args->event,args->pollfd,args->timeout); EventWorker(int tid,ULONG_PTR args,EventWorkerArgs* eargs) { poll pollptr(eargs->ssocket, eargs->event, eargs->pollfd, eargs->timeout); int wait=0; EVENTLOOP: try { wait=pollptr.waitEventHandler(args->timeout); wait=pollptr.waitEventHandler(eargs->timeout); for(int i =0; i<wait; ++i){ try{ switch (pollptr.pollState(i)) { Loading Loading @@ -418,7 +418,7 @@ EVENTLOOP: raise(SIGINT); } void event::runEventloop(void *args) { void event::runEventloop(ULONG_PTR args) { NetException exception; signal(SIGPIPE, SIG_IGN); Loading Loading @@ -455,7 +455,7 @@ MAINWORKERLOOP: for (int i = 0; i < threads; i++) { try { threadpool.push_back( std::thread([&eargs,i]{ EventWorker(i,&eargs); EventWorker(i,args,&eargs); })); } catch (NetException& e) { throw e; Loading src/event/iocp.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ namespace netplus { LeaveCriticalSection(&g_csClientList); } void AcceptConnection(int tid,void *args){ void AcceptConnection(int tid,ULONG_PTR args){ EnterCriticalSection(&g_csClientList); client* pClientContext = new client(g_eventapi); pClientContext->OpCode=OP_READ; Loading Loading @@ -196,19 +196,19 @@ RECONNECT: friend class EventWorker; }; void eventapi::RequestEvent(con* curcon, const int tid, void* args) { void eventapi::RequestEvent(con* curcon, const int tid, ULONG_PTR args) { //dummy }; void eventapi::ResponseEvent(con* curcon, const int tid, void* args) { void eventapi::ResponseEvent(con* curcon, const int tid, ULONG_PTR args) { //dummy }; void eventapi::ConnectEvent(con* curcon, const int tid, void* args) { void eventapi::ConnectEvent(con* curcon, const int tid, ULONG_PTR args) { //dummy }; void eventapi::DisconnectEvent(con* curcon, const int tid, void* args) { void eventapi::DisconnectEvent(con* curcon, const int tid, ULONG_PTR args) { //dummy }; Loading Loading @@ -266,7 +266,7 @@ RECONNECT: class EventWorker { public: EventWorker(int tid, EventWorkerArgs* args) { EventWorker(int tid, ULONG_PTR args, EventWorkerArgs* eargs) { ULONG_PTR lpContext = 0; OVERLAPPED* pOverlapped = nullptr; client* pClientContext = nullptr; Loading @@ -277,7 +277,7 @@ RECONNECT: for (;;){ int bReturn = GetQueuedCompletionStatus( args->eviocp, eargs->eviocp, &dwBytesTransfered, &lpContext, &pOverlapped, Loading @@ -290,11 +290,11 @@ RECONNECT: pClientContext = (client*)lpContext; if ((bReturn==0) && (0 == dwBytesTransfered)) { args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); continue; } EnterCriticalSection(&args->evpoll->g_csClientList); EnterCriticalSection(&eargs->evpoll->g_csClientList); std::cerr << pClientContext->OpCode << std::endl; Loading @@ -318,12 +318,12 @@ RECONNECT: if ((SOCKET_ERROR == ret) && (WSA_IO_PENDING != WSAGetLastError())){ //Let's not work with this client args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); } pClientContext->CurCon->SendData.resize(dwBytes); args->event->ResponseEvent(pClientContext->CurCon, tid, args); eargs->event->ResponseEvent(pClientContext->CurCon, tid, args); } else { pClientContext->OpCode=poll::OP_WRITE; Loading @@ -342,12 +342,12 @@ RECONNECT: if ((SOCKET_ERROR == ret) && (WSA_IO_PENDING != WSAGetLastError())) { std::cerr << "Thread " << tid << " : Error occurred while executing WSARecv()." << std::endl; //Let's not work with this client args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); } pClientContext->CurCon->RecvData.append(pClientContext->m_pwbuf.buf, dwBytes); args->event->RequestEvent(pClientContext->CurCon, tid, args); eargs->event->RequestEvent(pClientContext->CurCon, tid, args); } break; Loading @@ -370,12 +370,12 @@ RECONNECT: std::cerr << "Thread " << tid << " <<: Error occurred while executing WSASend()." << std::endl; //Let's not work with this client args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); } pClientContext->CurCon->SendData.resize(dwBytes); args->event->ResponseEvent(pClientContext->CurCon, tid, args); eargs->event->ResponseEvent(pClientContext->CurCon, tid, args); if (pClientContext->CurCon->SendData.empty()) { pClientContext->OpCode = poll::OP_READ; Loading @@ -384,10 +384,10 @@ RECONNECT: break; default: args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); break; } // switch LeaveCriticalSection(&args->evpoll->g_csClientList); LeaveCriticalSection(&eargs->evpoll->g_csClientList); } // while } }; Loading Loading @@ -425,8 +425,8 @@ RECONNECT: for (int i = 1; i < threads; i++) { try { threadpool.push_back(std::thread([&eargs, i] { EventWorker(i, &eargs); threadpool.push_back(std::thread([&eargs,args,i] { EventWorker(i,args, &eargs); })); } catch (NetException& e) { Loading Loading @@ -468,7 +468,7 @@ RECONNECT: WSAEnumNetworkEvents(_ServerSocket->fd(), g_hAcceptEvent, &WSAEvents); if ((WSAEvents.lNetworkEvents & FD_ACCEPT) && (0 == WSAEvents.iErrorCode[FD_ACCEPT_BIT])) { try { evpoll.AcceptConnection(0, &eargs); evpoll.AcceptConnection(0,args); } catch (NetException& e) { std::cerr << e.what() << std::endl; } Loading src/event/kqueue.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -421,7 +421,7 @@ EVENTLOOP: event::~event() { } void event::runEventloop(void *args) { void event::runEventloop() { NetException exception; signal(SIGPIPE, SIG_IGN); Loading src/eventapi.h +4 −4 Original line number Diff line number Diff line Loading @@ -45,10 +45,10 @@ namespace netplus { class eventapi { public: /*HTTP API Events*/ virtual void RequestEvent(con *curcon,const int tid,void *args); virtual void ResponseEvent(con *curcon,const int tid,void *args); virtual void ConnectEvent(con *curcon,const int tid,void *args); virtual void DisconnectEvent(con *curcon,const int tid,void *args); virtual void RequestEvent(con *curcon,const int tid,ULONG_PTR args); virtual void ResponseEvent(con *curcon,const int tid, ULONG_PTR args); virtual void ConnectEvent(con *curcon,const int tid, ULONG_PTR args); virtual void DisconnectEvent(con *curcon,const int tid, ULONG_PTR args); /*memory allocation*/ virtual void CreateConnetion(con **curon)=0; Loading Loading
src/event/epoll.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -325,12 +325,12 @@ namespace netplus { class EventWorker { public: EventWorker(int tid,EventWorkerArgs* args) { poll pollptr(args->ssocket,args->event,args->pollfd,args->timeout); EventWorker(int tid,ULONG_PTR args,EventWorkerArgs* eargs) { poll pollptr(eargs->ssocket, eargs->event, eargs->pollfd, eargs->timeout); int wait=0; EVENTLOOP: try { wait=pollptr.waitEventHandler(args->timeout); wait=pollptr.waitEventHandler(eargs->timeout); for(int i =0; i<wait; ++i){ try{ switch (pollptr.pollState(i)) { Loading Loading @@ -418,7 +418,7 @@ EVENTLOOP: raise(SIGINT); } void event::runEventloop(void *args) { void event::runEventloop(ULONG_PTR args) { NetException exception; signal(SIGPIPE, SIG_IGN); Loading Loading @@ -455,7 +455,7 @@ MAINWORKERLOOP: for (int i = 0; i < threads; i++) { try { threadpool.push_back( std::thread([&eargs,i]{ EventWorker(i,&eargs); EventWorker(i,args,&eargs); })); } catch (NetException& e) { throw e; Loading
src/event/iocp.cpp +20 −20 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ namespace netplus { LeaveCriticalSection(&g_csClientList); } void AcceptConnection(int tid,void *args){ void AcceptConnection(int tid,ULONG_PTR args){ EnterCriticalSection(&g_csClientList); client* pClientContext = new client(g_eventapi); pClientContext->OpCode=OP_READ; Loading Loading @@ -196,19 +196,19 @@ RECONNECT: friend class EventWorker; }; void eventapi::RequestEvent(con* curcon, const int tid, void* args) { void eventapi::RequestEvent(con* curcon, const int tid, ULONG_PTR args) { //dummy }; void eventapi::ResponseEvent(con* curcon, const int tid, void* args) { void eventapi::ResponseEvent(con* curcon, const int tid, ULONG_PTR args) { //dummy }; void eventapi::ConnectEvent(con* curcon, const int tid, void* args) { void eventapi::ConnectEvent(con* curcon, const int tid, ULONG_PTR args) { //dummy }; void eventapi::DisconnectEvent(con* curcon, const int tid, void* args) { void eventapi::DisconnectEvent(con* curcon, const int tid, ULONG_PTR args) { //dummy }; Loading Loading @@ -266,7 +266,7 @@ RECONNECT: class EventWorker { public: EventWorker(int tid, EventWorkerArgs* args) { EventWorker(int tid, ULONG_PTR args, EventWorkerArgs* eargs) { ULONG_PTR lpContext = 0; OVERLAPPED* pOverlapped = nullptr; client* pClientContext = nullptr; Loading @@ -277,7 +277,7 @@ RECONNECT: for (;;){ int bReturn = GetQueuedCompletionStatus( args->eviocp, eargs->eviocp, &dwBytesTransfered, &lpContext, &pOverlapped, Loading @@ -290,11 +290,11 @@ RECONNECT: pClientContext = (client*)lpContext; if ((bReturn==0) && (0 == dwBytesTransfered)) { args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); continue; } EnterCriticalSection(&args->evpoll->g_csClientList); EnterCriticalSection(&eargs->evpoll->g_csClientList); std::cerr << pClientContext->OpCode << std::endl; Loading @@ -318,12 +318,12 @@ RECONNECT: if ((SOCKET_ERROR == ret) && (WSA_IO_PENDING != WSAGetLastError())){ //Let's not work with this client args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); } pClientContext->CurCon->SendData.resize(dwBytes); args->event->ResponseEvent(pClientContext->CurCon, tid, args); eargs->event->ResponseEvent(pClientContext->CurCon, tid, args); } else { pClientContext->OpCode=poll::OP_WRITE; Loading @@ -342,12 +342,12 @@ RECONNECT: if ((SOCKET_ERROR == ret) && (WSA_IO_PENDING != WSAGetLastError())) { std::cerr << "Thread " << tid << " : Error occurred while executing WSARecv()." << std::endl; //Let's not work with this client args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); } pClientContext->CurCon->RecvData.append(pClientContext->m_pwbuf.buf, dwBytes); args->event->RequestEvent(pClientContext->CurCon, tid, args); eargs->event->RequestEvent(pClientContext->CurCon, tid, args); } break; Loading @@ -370,12 +370,12 @@ RECONNECT: std::cerr << "Thread " << tid << " <<: Error occurred while executing WSASend()." << std::endl; //Let's not work with this client args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); } pClientContext->CurCon->SendData.resize(dwBytes); args->event->ResponseEvent(pClientContext->CurCon, tid, args); eargs->event->ResponseEvent(pClientContext->CurCon, tid, args); if (pClientContext->CurCon->SendData.empty()) { pClientContext->OpCode = poll::OP_READ; Loading @@ -384,10 +384,10 @@ RECONNECT: break; default: args->evpoll->RemoveFromClientList(pClientContext); eargs->evpoll->RemoveFromClientList(pClientContext); break; } // switch LeaveCriticalSection(&args->evpoll->g_csClientList); LeaveCriticalSection(&eargs->evpoll->g_csClientList); } // while } }; Loading Loading @@ -425,8 +425,8 @@ RECONNECT: for (int i = 1; i < threads; i++) { try { threadpool.push_back(std::thread([&eargs, i] { EventWorker(i, &eargs); threadpool.push_back(std::thread([&eargs,args,i] { EventWorker(i,args, &eargs); })); } catch (NetException& e) { Loading Loading @@ -468,7 +468,7 @@ RECONNECT: WSAEnumNetworkEvents(_ServerSocket->fd(), g_hAcceptEvent, &WSAEvents); if ((WSAEvents.lNetworkEvents & FD_ACCEPT) && (0 == WSAEvents.iErrorCode[FD_ACCEPT_BIT])) { try { evpoll.AcceptConnection(0, &eargs); evpoll.AcceptConnection(0,args); } catch (NetException& e) { std::cerr << e.what() << std::endl; } Loading
src/event/kqueue.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -421,7 +421,7 @@ EVENTLOOP: event::~event() { } void event::runEventloop(void *args) { void event::runEventloop() { NetException exception; signal(SIGPIPE, SIG_IGN); Loading
src/eventapi.h +4 −4 Original line number Diff line number Diff line Loading @@ -45,10 +45,10 @@ namespace netplus { class eventapi { public: /*HTTP API Events*/ virtual void RequestEvent(con *curcon,const int tid,void *args); virtual void ResponseEvent(con *curcon,const int tid,void *args); virtual void ConnectEvent(con *curcon,const int tid,void *args); virtual void DisconnectEvent(con *curcon,const int tid,void *args); virtual void RequestEvent(con *curcon,const int tid,ULONG_PTR args); virtual void ResponseEvent(con *curcon,const int tid, ULONG_PTR args); virtual void ConnectEvent(con *curcon,const int tid, ULONG_PTR args); virtual void DisconnectEvent(con *curcon,const int tid, ULONG_PTR args); /*memory allocation*/ virtual void CreateConnetion(con **curon)=0; Loading