Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows iopc no close #1984

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/platform/tcp_stream_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,29 @@ test_tcp_stream(void)
nng_stream_free(c2);
}

void
test_tcp_listen_accept_cancel(void)
{
nng_stream_listener *l;
char *addr;
nng_aio *aio;

nng_log_set_logger(nng_stderr_logger);
NUTS_ADDR(addr, "tcp");
NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL));

// start a listening stream listener but do not call accept
NUTS_PASS(nng_stream_listener_alloc(&l, addr));
NUTS_PASS(nng_stream_listener_listen(l));
nng_stream_listener_accept(l, aio);
nng_msleep(100);
nng_aio_free(aio);
nng_stream_listener_close(l);
nng_stream_listener_free(l);
}

NUTS_TESTS = {
{ "tcp stream", test_tcp_stream },
{ "tcp stream listen accept cancel", test_tcp_listen_accept_cancel },
{ NULL, NULL },
};
13 changes: 8 additions & 5 deletions src/platform/windows/win_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ win_io_handler(void *arg)
int rv;

ok = GetQueuedCompletionStatus(
win_io_h, &cnt, &key, &olpd, INFINITE);
win_io_h, &cnt, &key, &olpd, 5000);

if (olpd == NULL) {
// Completion port closed...
NNI_ASSERT(ok == FALSE);
break;
}

Expand Down Expand Up @@ -124,12 +123,16 @@ nni_win_io_sysfini(void)
HANDLE h;

if ((h = win_io_h) != NULL) {
// send wakeups in case closing the handle doesn't work
for (i = 0; i < win_io_nthr; i++) {
PostQueuedCompletionStatus(h, 0, 0, NULL);
}
CloseHandle(h);
for (i = 0; i < win_io_nthr; i++) {
nni_thr_fini(&win_io_thrs[i]);
}
win_io_h = NULL;
}
for (i = 0; i < win_io_nthr; i++) {
nni_thr_fini(&win_io_thrs[i]);
}

NNI_FREE_STRUCTS(win_io_thrs, win_io_nthr);
}
Expand Down
Loading
Loading