Exposed ports see a constant stream of scanners and HTTP probes. Every TLS
handshake attempt logged an ioctlsocket(FIONBIO=0) failure, but WSAEINVAL is
the documented result once WSAEventSelect owns the listening socket and the
code already falls back to select; that line alone accounted for 6678 of the
8970 "handshake" lines in a four-day log. It is now logged only for other
error codes.
A failed handshake used to print three or four lines (recv EOF,
AcceptSecurityContext, final status, failed-for-IP) with no per-peer dedup,
and WS upgrade failures printed once per HTTP probe. ServerTlsSession now
records a human-readable reason (Schannel status name for ASC failures)
instead of logging per connection; IOCPServer prints one line per peer per
hour with the reason and a suppressed count, for both TLS and WS. Peer
close_notify is a normal shutdown and is no longer logged; MCP TLS failures
now carry the same reason.
Failure details are copied before the context's I/O reference is released,
so the log path cannot touch a context that another thread may recycle. No
handshake, crypto or connection behaviour changes.
Verified with a Debug x64 build and a live probe run: six failed connections
to the device port produced exactly one TLS and one WS line, with no
ioctlsocket lines.
Co-Authored-By: deepseek-flash