From 302436515c9d659b1950eaed2ffc45dd745958a6 Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Sat, 26 Oct 2019 19:38:59 +0200 Subject: [PATCH] Problem: windows socket error number cleared before saved to saved_errno Solution: call tune_socket only if connect was successful --- src/ip.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ip.cpp b/src/ip.cpp index db8bf0ca..2b59b0bd 100644 --- a/src/ip.cpp +++ b/src/ip.cpp @@ -449,20 +449,23 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_) } // Listen for incoming connections. - if (rc != SOCKET_ERROR) + if (rc != SOCKET_ERROR) { rc = listen (listener, 1); + } // Connect writer to the listener. - if (rc != SOCKET_ERROR) + if (rc != SOCKET_ERROR) { rc = connect (*w_, reinterpret_cast (&addr), sizeof addr); - - // Set TCP_NODELAY on writer socket. - tune_socket (*w_); + } // Accept connection from writer. - if (rc != SOCKET_ERROR) + if (rc != SOCKET_ERROR) { + // Set TCP_NODELAY on writer socket. + tune_socket (*w_); + *r_ = accept (listener, NULL, NULL); + } // Send/receive large chunk to work around TCP slow start // This code is a workaround for #1608