Commit 6760fd77 authored by jan.koester's avatar jan.koester
Browse files

tests

parent 7e0a40d8
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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 {
+1 −1
Original line number Diff line number Diff line
@@ -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)