Skip to content

Commit 53aa139

Browse files
authored
Fixed: High CPU usage and log file growing up (PowerShell/Win32-OpenSSH#606)
Added fix recommended by @richard-browne [here](https://github.com/PowerShell/Win32-OpenSSH/files/414456/sockio.c.txt)
1 parent 5ea573d commit 53aa139

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

contrib/win32/win32compat/socketio.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,20 @@ int
104104
socketio_acceptEx(struct w32_io* pio)
105105
{
106106
struct acceptEx_context *context;
107+
struct sockaddr_storage addr; int addrlen = sizeof addr;
108+
107109
debug5("acceptEx - io:%p", pio);
108110
context = (struct acceptEx_context *)pio->internal.context;
109111
ResetEvent(pio->read_overlapped.hEvent);
110112

113+
if (getsockname(pio->sock, &addr, &addrlen) == SOCKET_ERROR) {
114+
errno = errno_from_WSALastError();
115+
debug("acceptEx - getsockname() ERROR:%d, io:%p", errno, pio);
116+
return -1;
117+
}
118+
111119
/* create accepting socket */
112-
context->accept_socket = socket(AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
120+
context->accept_socket = socket(addr.ss_family, SOCK_STREAM, IPPROTO_TCP);
113121
if (context->accept_socket == INVALID_SOCKET) {
114122
errno = errno_from_WSALastError();
115123
debug3("acceptEx - socket() ERROR:%d, io:%p", errno, pio);

0 commit comments

Comments
 (0)