diff --git a/lib/core-net/network.c b/lib/core-net/network.c index feab9fa91..c53d4fb08 100644 --- a/lib/core-net/network.c +++ b/lib/core-net/network.c @@ -297,12 +297,14 @@ lws_socket_bind(struct lws_vhost *vhost, lws_sockfd_type sockfd, int port, } else #endif if (n < 0) { + int _lws_errno = LWS_ERRNO; + lwsl_err("ERROR on binding fd %d to port %d (%d %d)\n", - sockfd, port, n, LWS_ERRNO); + sockfd, port, n, _lws_errno); /* if something already listening, tell caller to fail permanently */ - if (LWS_ERRNO == LWS_EADDRINUSE) + if (_lws_errno == LWS_EADDRINUSE) return LWS_ITOSA_BUSY; /* otherwise ask caller to retry later */ diff --git a/lib/roles/http/client/client-handshake.c b/lib/roles/http/client/client-handshake.c index d891c6d6f..efc3d563c 100644 --- a/lib/roles/http/client/client-handshake.c +++ b/lib/roles/http/client/client-handshake.c @@ -582,13 +582,15 @@ ads_known: m = connect(wsi->desc.sockfd, (const struct sockaddr *)psa, n); if (m == -1) { - lwsl_debug("%s: connect says errno: %d\n", __func__, LWS_ERRNO); + int errno_copy = LWS_ERRNO; - if (LWS_ERRNO != LWS_EALREADY && - LWS_ERRNO != LWS_EINPROGRESS && - LWS_ERRNO != LWS_EWOULDBLOCK + lwsl_debug("%s: connect says errno: %d\n", __func__, errno_copy); + + if (errno_copy != LWS_EALREADY && + errno_copy != LWS_EINPROGRESS && + errno_copy != LWS_EWOULDBLOCK #ifdef _WIN32 - && LWS_ERRNO != WSAEINVAL + && errno_copy != WSAEINVAL #endif ) { #if defined(_DEBUG)