From 932906753bfe506e712f1b705a35d0c118aa0cef Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Thu, 20 Jan 2011 10:48:42 +0000 Subject: [PATCH] * bugfix #351: fix udp_send hang if UDP checksum error. --- Changelog | 1 + net.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Changelog b/Changelog index ee56f6f0..46157a36 100644 --- a/Changelog +++ b/Changelog @@ -10,6 +10,7 @@ * ldns-test-edns: new example tool that detects EDNS support. * fix ldns_resolver_send without openssl. * bugfix #342: patch for support for more CERT key types (RFC4398). + * bugfix #351: fix udp_send hang if UDP checksum error. 1.6.7 2010-11-08 * EXPERIMENTAL ecdsa implementation, please do not enable on real diff --git a/net.c b/net.c index f6a51bf4..85a8f506 100644 --- a/net.c +++ b/net.c @@ -305,6 +305,11 @@ ldns_udp_send(uint8_t **result, ldns_buffer *qbin, const struct sockaddr_storage return LDNS_STATUS_NETWORK_ERR; } + /* set to nonblocking, so if the checksum is bad, it becomes + * an EGAIN error and the ldns_udp_send function does not block, + * but returns a 'NETWORK_ERROR' much like a timeout. */ + ldns_sock_nonblock(sockfd); + answer = ldns_udp_read_wire(sockfd, answer_size, NULL, NULL); #ifndef USE_WINSOCK close(sockfd); -- 2.47.3