From f59b487a694a0473eb1ebcc83a3b6e780d82a5cc Mon Sep 17 00:00:00 2001 From: Vladimir Homutov Date: Tue, 20 Jul 2021 12:04:58 +0300 Subject: [PATCH] Core: fixed errno clobbering in ngx_sendmsg(). This was broken by 2dfd313f22f2. --- src/os/unix/ngx_udp_sendmsg_chain.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/os/unix/ngx_udp_sendmsg_chain.c b/src/os/unix/ngx_udp_sendmsg_chain.c index 78b497ea0..b29b8d318 100644 --- a/src/os/unix/ngx_udp_sendmsg_chain.c +++ b/src/os/unix/ngx_udp_sendmsg_chain.c @@ -398,15 +398,6 @@ eintr: n = sendmsg(c->fd, msg, flags); -#if (NGX_DEBUG) - for (i = 0, size = 0; i < (size_t) msg->msg_iovlen; i++) { - size += msg->msg_iov[i].iov_len; - } - - ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, - "sendmsg: %z of %uz", n, size); -#endif - if (n == -1) { err = ngx_errno; @@ -428,5 +419,14 @@ eintr: } } +#if (NGX_DEBUG) + for (i = 0, size = 0; i < (size_t) msg->msg_iovlen; i++) { + size += msg->msg_iov[i].iov_len; + } + + ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, + "sendmsg: %z of %uz", n, size); +#endif + return n; }