Loading src/event/kqueue.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -1174,13 +1174,15 @@ int netplus::socketwait::waitReadMulti(std::vector<socket*> &sockets, bool netplus::socketwait::isDisconnected(socket &sock) { SOCKET fd = sock.fd(); if (fd < 0) return true; struct kevent change; EV_SET(&change, fd, EVFILT_READ, EV_ADD | EV_ONESHOT, 0, 0, nullptr); struct kevent out; struct kevent out{}; struct timespec ts = {0, 0}; int r = ::kevent(_handle, &change, 1, &out, 1, &ts); if (r > 0 && (out.flags & EV_EOF)) return true; return false; // EV_EOF already reports a peer FIN; registration failures must not // make an invalid socket look reusable either. return r < 0 || (r > 0 && (out.flags & (EV_EOF | EV_ERROR))); } namespace netplus { Loading test/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -298,7 +298,7 @@ else() endif() add_test(NAME threadpool_bounded_queue_test COMMAND threadpool_bounded_queue_test) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(UNIX) add_executable(socketwait_disconnect_test socketwait_disconnect_test.cpp) target_link_libraries(socketwait_disconnect_test netplus-static) add_test(NAME socketwait_disconnect_test COMMAND socketwait_disconnect_test) Loading Loading
src/event/kqueue.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -1174,13 +1174,15 @@ int netplus::socketwait::waitReadMulti(std::vector<socket*> &sockets, bool netplus::socketwait::isDisconnected(socket &sock) { SOCKET fd = sock.fd(); if (fd < 0) return true; struct kevent change; EV_SET(&change, fd, EVFILT_READ, EV_ADD | EV_ONESHOT, 0, 0, nullptr); struct kevent out; struct kevent out{}; struct timespec ts = {0, 0}; int r = ::kevent(_handle, &change, 1, &out, 1, &ts); if (r > 0 && (out.flags & EV_EOF)) return true; return false; // EV_EOF already reports a peer FIN; registration failures must not // make an invalid socket look reusable either. return r < 0 || (r > 0 && (out.flags & (EV_EOF | EV_ERROR))); } namespace netplus { Loading
test/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -298,7 +298,7 @@ else() endif() add_test(NAME threadpool_bounded_queue_test COMMAND threadpool_bounded_queue_test) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(UNIX) add_executable(socketwait_disconnect_test socketwait_disconnect_test.cpp) target_link_libraries(socketwait_disconnect_test netplus-static) add_test(NAME socketwait_disconnect_test COMMAND socketwait_disconnect_test) Loading