]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
resolv_test.c: also cope with CONNREFUSED errors returned by recvfrom
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 10 Sep 2017 15:41:03 +0000 (17:41 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 24 Sep 2017 23:11:43 +0000 (01:11 +0200)
server_thread_udp_process_one already takes care of calling sendto()
instead of xsendto to be able to ignore the case where the client has
closed the socket.  Depending on the TCP/IP stack behavior, this error
could be notified later through recvfrom(), so we need to ignore it
there too.

* support/resolv_test.c (server_thread_udp_process_one): Call recvfrom
instead of xrecvfrom, and ignore ECONNREFUSED errors.

ChangeLog
support/resolv_test.c

index 1c44a53c75ec7b2b2e097b6579922ab3de8b0f52..84b1937ce019978e70bfba7ad74577bb4ff05535 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,8 @@
        (CMSG_FIRSTHDR, __cmsg_nxthdr): Use (struct cmsghdr *) 0 instead of
        NULL.
        * bits/socket.h: Likewise.
+       * support/resolv_test.c (server_thread_udp_process_one): Call recvfrom
+       instead of xrecvfrom, and ignore ECONNREFUSED errors.
 
 2017-09-22  Joseph Myers  <joseph@codesourcery.com>
 
index 1625dcf43a204434d395a6fbf8524d06c5f403fc..c3325b89b156910a54fcb30b83c5b33e2ea0bea9 100644 (file)
@@ -600,7 +600,7 @@ server_thread_udp_process_one (struct resolv_test *obj, int server_index)
   unsigned char query[512];
   struct sockaddr_storage peer;
   socklen_t peerlen = sizeof (peer);
-  size_t length = xrecvfrom (obj->servers[server_index].socket_udp,
+  ssize_t length = recvfrom (obj->servers[server_index].socket_udp,
                              query, sizeof (query), 0,
                              (struct sockaddr *) &peer, &peerlen);
   /* Check for termination.  */
@@ -613,6 +613,12 @@ server_thread_udp_process_one (struct resolv_test *obj, int server_index)
       return false;
   }
 
+  if (length < 0)
+    {
+      /* The other end had closed the socket, and we are notified only now. */
+      TEST_VERIFY_EXIT (errno == ECONNREFUSED);
+      return true;
+    }
 
   struct query_info qinfo;
   parse_query (&qinfo, query, length);