Skip to content

Commit 17e9629

Browse files
committed
Ignore ICMP port unreachable on the DTLS server socket on Windows
Windows fails to execute the next recvfrom() call on a UDP socket with WSAECONNRESET after a sent datagram is returned as an ICMP port unreachable, such as a close notification to a client that has already disconnected. The socket is the port of every peer, so accept() fails for the next client. Disabled with SIO_UDP_CONNRESET, since Linux never reports this on an unconnected socket.
1 parent a98fee3 commit 17e9629

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎ext/openssl/xp_dtls.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#include <openssl/hmac.h>
3232
#include <openssl/rand.h>
3333
#include <openssl/crypto.h>
34+
#ifdef PHP_WIN32
35+
#include <mstcpip.h>
36+
# ifndef SIO_UDP_CONNRESET
37+
# define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR, 12)
38+
# endif
39+
#endif
3440

3541
#ifdef HAVE_DTLS
3642

@@ -520,6 +526,13 @@ int php_openssl_dtls_listen(php_stream *stream, php_openssl_netstream_data_t *ss
520526
port->stream = stream;
521527
port->listener = sslsock;
522528
port->fd = sslsock->s.socket;
529+
#ifdef PHP_WIN32
530+
{
531+
BOOL report = FALSE;
532+
DWORD bytes;
533+
WSAIoctl(port->fd, SIO_UDP_CONNRESET, &report, sizeof(report), NULL, 0, &bytes, NULL, NULL);
534+
}
535+
#endif
523536
port->max_pending = PHP_OPENSSL_DTLS_MAX_PENDING;
524537
port->pending_timeout = PHP_OPENSSL_DTLS_PENDING_TIMEOUT;
525538
GET_VER_OPT_LONG("dtls_max_pending", port->max_pending);

0 commit comments

Comments
 (0)