mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 22:38:30 +00:00
Fix NT accept/connect not initializing with SO_UPDATE_*_CONTEXT (#1164)
This commit is contained in:
parent
2f3c6e7cc3
commit
624119ea38
5 changed files with 173 additions and 8 deletions
|
@ -87,10 +87,6 @@ static int sys_accept_nt_start(int64_t handle, struct NtOverlapped *overlap,
|
|||
if (g_acceptex.lpAcceptEx(args->listensock, handle, args->buffer, 0,
|
||||
sizeof(args->buffer->local),
|
||||
sizeof(args->buffer->remote), 0, overlap)) {
|
||||
// inherit properties of listening socket
|
||||
unassert(!__imp_setsockopt(args->listensock, SOL_SOCKET,
|
||||
kNtSoUpdateAcceptContext, &handle,
|
||||
sizeof(handle)));
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -123,6 +119,13 @@ textwindows int sys_accept_nt(struct Fd *f, struct sockaddr_storage *addr,
|
|||
goto Finish;
|
||||
}
|
||||
|
||||
// inherit properties of listening socket
|
||||
// errors ignored as if f->handle was created before forking
|
||||
// this fails with WSAENOTSOCK, see
|
||||
// https://github.com/jart/cosmopolitan/issues/1174
|
||||
__imp_setsockopt(resources.handle, SOL_SOCKET, kNtSoUpdateAcceptContext,
|
||||
&f->handle, sizeof(f->handle));
|
||||
|
||||
// create file descriptor for new socket
|
||||
// don't inherit the file open mode bits
|
||||
int oflags = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue