Loading src/event/kqueue.cpp +15 −7 Changes for src/event/kqueue.cpp: 15 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -197,12 +197,11 @@ namespace netplus { ccon->lasteventime = time(nullptr); con *sccon= ccon.release(); struct kevent setevent {}; setevent.udata = ccon.release(); struct kevent setevent {0}; setevent.udata =sccon; EV_SET(&setevent, ccon->csock->fd(), EVFILT_READ, EV_ADD | EV_ONESHOT,0,0,sccon); EV_SET(&setevent, ccon->csock->fd(), EVFILT_READ, EV_ADD | EV_ONESHOT,0,0,ccon.get()); int estate = kevent(_pollFD, &setevent, 1, nullptr, 0, nullptr); Loading @@ -213,10 +212,10 @@ namespace netplus { throw exception; } evconnection ->ConnectEvent(*sccon,tid,args); evconnection ->ConnectEvent(*ccon,tid,args); { std::lock_guard<std::mutex> clock(sccon->event_mutex),global_lock(POLL_HANDLER_MUTEX); CONNECTIONS.emplace(sccon->csock->fd(),sccon); std::lock_guard<std::mutex> clock(ccon->event_mutex),global_lock(POLL_HANDLER_MUTEX); CONNECTIONS.emplace(ccon->csock->fd(),ccon.release()); } }; Loading Loading @@ -393,6 +392,8 @@ 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; Loading @@ -413,6 +414,13 @@ public: // 2. Retrieve event flags (may throw on EV_ERROR) events = pollptr.getEventFlags(i); // Check for error/hangs (EPOLLHUP/EPOLLERR) if (events & (EV_ERROR| EV_EOF)) { // Treat as close event if any of these flags are set pollptr.CloseEventHandler(i,tid,args); continue; } // 4. Prioritize read events (new data from client) if (events & EVFILT_READ) { pollptr.ReadEventHandler(i, tid, args); Loading Loading
src/event/kqueue.cpp +15 −7 Changes for src/event/kqueue.cpp: 15 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -197,12 +197,11 @@ namespace netplus { ccon->lasteventime = time(nullptr); con *sccon= ccon.release(); struct kevent setevent {}; setevent.udata = ccon.release(); struct kevent setevent {0}; setevent.udata =sccon; EV_SET(&setevent, ccon->csock->fd(), EVFILT_READ, EV_ADD | EV_ONESHOT,0,0,sccon); EV_SET(&setevent, ccon->csock->fd(), EVFILT_READ, EV_ADD | EV_ONESHOT,0,0,ccon.get()); int estate = kevent(_pollFD, &setevent, 1, nullptr, 0, nullptr); Loading @@ -213,10 +212,10 @@ namespace netplus { throw exception; } evconnection ->ConnectEvent(*sccon,tid,args); evconnection ->ConnectEvent(*ccon,tid,args); { std::lock_guard<std::mutex> clock(sccon->event_mutex),global_lock(POLL_HANDLER_MUTEX); CONNECTIONS.emplace(sccon->csock->fd(),sccon); std::lock_guard<std::mutex> clock(ccon->event_mutex),global_lock(POLL_HANDLER_MUTEX); CONNECTIONS.emplace(ccon->csock->fd(),ccon.release()); } }; Loading Loading @@ -393,6 +392,8 @@ 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; Loading @@ -413,6 +414,13 @@ public: // 2. Retrieve event flags (may throw on EV_ERROR) events = pollptr.getEventFlags(i); // Check for error/hangs (EPOLLHUP/EPOLLERR) if (events & (EV_ERROR| EV_EOF)) { // Treat as close event if any of these flags are set pollptr.CloseEventHandler(i,tid,args); continue; } // 4. Prioritize read events (new data from client) if (events & EVFILT_READ) { pollptr.ReadEventHandler(i, tid, args); Loading