[nginx] Resolver: close UDP socket on error or incomplete send.

Ruslan Ermilov ru at nginx.com
Wed May 23 09:03:04 UTC 2018


details:   http://hg.nginx.org/nginx/rev/a90f7812de35
branches:  
changeset: 7276:a90f7812de35
user:      Ruslan Ermilov <ru at nginx.com>
date:      Wed May 23 10:41:38 2018 +0300
description:
Resolver: close UDP socket on error or incomplete send.

diffstat:

 src/core/ngx_resolver.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r e15bf978447e -r a90f7812de35 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c	Wed May 23 10:41:29 2018 +0300
+++ b/src/core/ngx_resolver.c	Wed May 23 10:41:38 2018 +0300
@@ -1300,15 +1300,22 @@ ngx_resolver_send_udp_query(ngx_resolver
     n = ngx_send(rec->udp, query, qlen);
 
     if (n == NGX_ERROR) {
-        return NGX_ERROR;
+        goto failed;
     }
 
     if ((size_t) n != (size_t) qlen) {
         ngx_log_error(NGX_LOG_CRIT, &rec->log, 0, "send() incomplete");
-        return NGX_ERROR;
+        goto failed;
     }
 
     return NGX_OK;
+
+failed:
+
+    ngx_close_connection(rec->udp);
+    rec->udp = NULL;
+
+    return NGX_ERROR;
 }
 
 


More information about the nginx-devel mailing list