This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] resolv_test.c: also cope with CONNREFUSED errors returned by recvfrom
- From: Samuel Thibault <samuel dot thibault at ens-lyon dot org>
- To: libc-alpha at sourceware dot org
- Date: Mon, 25 Sep 2017 01:12:29 +0200
- Subject: Re: [PATCH] resolv_test.c: also cope with CONNREFUSED errors returned by recvfrom
- Authentication-results: sourceware.org; auth=none
- References: <20170910143816.v5tdzfyywtbi7aae@var.youpi.perso.aquilenet.fr>
Samuel Thibault, on dim. 10 sept. 2017 16:38:16 +0200, wrote:
> 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.
I have commited it.
> diff --git a/support/resolv_test.c b/support/resolv_test.c
> index 1625dcf43a..c3325b89b1 100644
> --- a/support/resolv_test.c
> +++ b/support/resolv_test.c
> @@ -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);
--
Samuel
<y> ça gaze ?
<l> prout
-+- #ens-mim - ouvrez les fenêtres ! -+-