From cf261da79a66a8c827ec1bce305ee4187680ded0 Mon Sep 17 00:00:00 2001 From: Mathias Berchtold Date: Thu, 30 May 2019 23:16:21 +0200 Subject: [PATCH] Fix netProbe write check Write at least 1 byte. This ensures that sockets are ready to use for writing. Windows specific: during the system startup, sockets can be created but the underlying buffers may not be setup yet. If this is the case Write fails with WSAENOBUFS: "An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full This fixes: https://github.com/jedisct1/dnscrypt-proxy/issues/841 --- dnscrypt-proxy/config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dnscrypt-proxy/config.go b/dnscrypt-proxy/config.go index 4b23c830..3efa1d8f 100644 --- a/dnscrypt-proxy/config.go +++ b/dnscrypt-proxy/config.go @@ -623,7 +623,10 @@ func netProbe(address string, timeout int) error { for tries := timeout; tries > 0; tries-- { pc, err := net.DialUDP("udp", nil, remoteUDPAddr) if err == nil { - _, err = pc.Write([]byte{}) + // Write at least 1 byte. This ensures that sockets are ready to use for writing. + // Windows specific: during the system startup, sockets can be created but the underlying buffers may not be setup yet. If this is the case + // Write fails with WSAENOBUFS: "An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full" + _, err = pc.Write([]byte{ 0 }) } if err != nil { if !retried {