Remove old ldns patch from FS-3110
This commit is contained in:
parent
33460064ac
commit
c1f884cd33
|
@ -1,323 +0,0 @@
|
|||
diff -ru b/ldns/ldns.h a/ldns/ldns.h
|
||||
--- b/ldns/ldns.h 2011-03-24 20:32:30.000000000 -0500
|
||||
+++ a/ldns/ldns.h 2011-03-24 20:29:03.000000000 -0500
|
||||
@@ -148,6 +148,16 @@
|
||||
/** EDNS flags */
|
||||
extern ldns_lookup_table ldns_edns_flags[];
|
||||
|
||||
+
|
||||
+#ifdef USE_WINSOCK
|
||||
+#define SOCK_INVALID INVALID_SOCKET
|
||||
+#define close_socket(_s) if (_s > SOCK_INVALID) {closesocket(_s); _s = SOCK_INVALID;}
|
||||
+#else
|
||||
+#define SOCK_INVALID -1
|
||||
+#define close_socket(_s) if (_s > SOCK_INVALID) {close(_s); _s = SOCK_INVALID;}
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
diff -ru b/net.c a/net.c
|
||||
--- b/net.c 2011-02-11 10:50:46.000000000 -0600
|
||||
+++ a/net.c 2011-03-24 20:28:15.000000000 -0500
|
||||
@@ -261,12 +261,18 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
+#ifndef WIN32
|
||||
+#include <poll.h>
|
||||
+#endif
|
||||
+
|
||||
/** wait for a socket to become ready */
|
||||
static int
|
||||
ldns_sock_wait(int sockfd, struct timeval timeout, int write)
|
||||
{
|
||||
- fd_set fds;
|
||||
int ret;
|
||||
+
|
||||
+#ifdef WIN32
|
||||
+ fd_set fds;
|
||||
#ifndef S_SPLINT_S
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(FD_SET_T sockfd, &fds);
|
||||
@@ -275,6 +281,26 @@
|
||||
ret = select(sockfd+1, NULL, &fds, NULL, &timeout);
|
||||
else
|
||||
ret = select(sockfd+1, &fds, NULL, NULL, &timeout);
|
||||
+#else
|
||||
+
|
||||
+ struct pollfd pfds[2];
|
||||
+ int x = 0;
|
||||
+
|
||||
+ memset(&pfds[0], 0, sizeof(pfds[0]) * 2);
|
||||
+
|
||||
+ pfds[0].fd = sockfd;
|
||||
+ pfds[0].events = POLLIN|POLLERR;
|
||||
+
|
||||
+ if (write) {
|
||||
+ pfds[0].events |= POLLOUT;
|
||||
+ }
|
||||
+
|
||||
+ ret = poll(pfds, 1, timeout.tv_sec * 1000 + timeout.tv_usec / 1000);
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
+
|
||||
if(ret == 0)
|
||||
/* timeout expired */
|
||||
return 0;
|
||||
@@ -299,11 +325,7 @@
|
||||
|
||||
/* wait for an response*/
|
||||
if(!ldns_sock_wait(sockfd, timeout, 0)) {
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(sockfd);
|
||||
-#else
|
||||
- closesocket(sockfd);
|
||||
-#endif
|
||||
+ close_socket(sockfd);
|
||||
return LDNS_STATUS_NETWORK_ERR;
|
||||
}
|
||||
|
||||
@@ -313,11 +335,7 @@
|
||||
ldns_sock_nonblock(sockfd);
|
||||
|
||||
answer = ldns_udp_read_wire(sockfd, answer_size, NULL, NULL);
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(sockfd);
|
||||
-#else
|
||||
- closesocket(sockfd);
|
||||
-#endif
|
||||
+ close_socket(sockfd);
|
||||
|
||||
if (*answer_size == 0) {
|
||||
/* oops */
|
||||
@@ -353,9 +371,10 @@
|
||||
|
||||
if ((sockfd = socket((int)((struct sockaddr*)to)->sa_family, SOCK_DGRAM,
|
||||
IPPROTO_UDP))
|
||||
- == -1) {
|
||||
+ == SOCK_INVALID) {
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
return sockfd;
|
||||
}
|
||||
|
||||
@@ -366,20 +385,20 @@
|
||||
int sockfd;
|
||||
|
||||
if ((sockfd = socket((int)((struct sockaddr*)to)->sa_family, SOCK_STREAM,
|
||||
- IPPROTO_TCP)) == -1) {
|
||||
+ IPPROTO_TCP)) == SOCK_INVALID) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* perform nonblocking connect, to be able to wait with select() */
|
||||
ldns_sock_nonblock(sockfd);
|
||||
- if (connect(sockfd, (struct sockaddr*)to, tolen) == -1) {
|
||||
+ if (connect(sockfd, (struct sockaddr*)to, tolen) == SOCK_INVALID) {
|
||||
#ifndef USE_WINSOCK
|
||||
#ifdef EINPROGRESS
|
||||
if(errno != EINPROGRESS) {
|
||||
#else
|
||||
if(1) {
|
||||
#endif
|
||||
- close(sockfd);
|
||||
+ close_socket(sockfd);
|
||||
return 0;
|
||||
}
|
||||
#else /* USE_WINSOCK */
|
||||
@@ -398,11 +417,7 @@
|
||||
socklen_t len = (socklen_t)sizeof(error);
|
||||
|
||||
if(!ldns_sock_wait(sockfd, timeout, 1)) {
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(sockfd);
|
||||
-#else
|
||||
- closesocket(sockfd);
|
||||
-#endif
|
||||
+ close_socket(sockfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -421,7 +436,7 @@
|
||||
continue; /* try again */
|
||||
#endif
|
||||
else if(error != 0) {
|
||||
- close(sockfd);
|
||||
+ close_socket(sockfd);
|
||||
/* error in errno for our user */
|
||||
errno = error;
|
||||
return 0;
|
||||
@@ -645,11 +660,7 @@
|
||||
}
|
||||
|
||||
answer = ldns_tcp_read_wire_timeout(sockfd, answer_size, timeout);
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(sockfd);
|
||||
-#else
|
||||
- closesocket(sockfd);
|
||||
-#endif
|
||||
+ close_socket(sockfd);
|
||||
|
||||
if (*answer_size == 0) {
|
||||
/* oops */
|
||||
@@ -782,7 +793,7 @@
|
||||
* @hostname is used */
|
||||
for (ns_i = 0;
|
||||
ns_i < ldns_resolver_nameserver_count(resolver) &&
|
||||
- resolver->_socket == 0;
|
||||
+ resolver->_socket == SOCK_INVALID;
|
||||
ns_i++) {
|
||||
ns = ldns_rdf2native_sockaddr_storage(
|
||||
resolver->_nameservers[ns_i],
|
||||
@@ -792,7 +803,7 @@
|
||||
ldns_resolver_timeout(resolver));
|
||||
}
|
||||
|
||||
- if (resolver->_socket == 0) {
|
||||
+ if (resolver->_socket == SOCK_INVALID) {
|
||||
ldns_pkt_free(query);
|
||||
LDNS_FREE(ns);
|
||||
return LDNS_STATUS_NETWORK_ERR;
|
||||
@@ -807,13 +818,7 @@
|
||||
if (status != LDNS_STATUS_OK) {
|
||||
/* RoRi: to prevent problems on subsequent calls to ldns_axfr_start
|
||||
we have to close the socket here! */
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(resolver->_socket);
|
||||
-#else
|
||||
- closesocket(resolver->_socket);
|
||||
-#endif
|
||||
- resolver->_socket = 0;
|
||||
-
|
||||
+ close_socket(resolver->_socket);
|
||||
return LDNS_STATUS_CRYPTO_TSIG_ERR;
|
||||
}
|
||||
}
|
||||
@@ -826,12 +831,8 @@
|
||||
if(!query_wire) {
|
||||
ldns_pkt_free(query);
|
||||
LDNS_FREE(ns);
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(resolver->_socket);
|
||||
-#else
|
||||
- closesocket(resolver->_socket);
|
||||
-#endif
|
||||
- resolver->_socket = 0;
|
||||
+
|
||||
+ close_socket(resolver->_socket);
|
||||
|
||||
return LDNS_STATUS_MEM_ERR;
|
||||
}
|
||||
@@ -843,12 +844,8 @@
|
||||
|
||||
/* RoRi: to prevent problems on subsequent calls to ldns_axfr_start
|
||||
we have to close the socket here! */
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(resolver->_socket);
|
||||
-#else
|
||||
- closesocket(resolver->_socket);
|
||||
-#endif
|
||||
- resolver->_socket = 0;
|
||||
+
|
||||
+ close_socket(resolver->_socket);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -862,12 +859,8 @@
|
||||
/* RoRi: to prevent problems on subsequent calls to ldns_axfr_start
|
||||
we have to close the socket here! */
|
||||
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(resolver->_socket);
|
||||
-#else
|
||||
- closesocket(resolver->_socket);
|
||||
-#endif
|
||||
- resolver->_socket = 0;
|
||||
+
|
||||
+ close_socket(resolver->_socket);
|
||||
|
||||
return LDNS_STATUS_NETWORK_ERR;
|
||||
}
|
||||
diff -ru b/resolver.c a/resolver.c
|
||||
--- b/resolver.c 2010-12-14 08:41:38.000000000 -0600
|
||||
+++ a/resolver.c 2011-03-24 20:07:17.000000000 -0500
|
||||
@@ -627,9 +627,7 @@
|
||||
r->_timeout.tv_sec = LDNS_DEFAULT_TIMEOUT_SEC;
|
||||
r->_timeout.tv_usec = LDNS_DEFAULT_TIMEOUT_USEC;
|
||||
|
||||
- /* TODO: fd=0 is actually a valid socket (stdin),
|
||||
- replace with -1 */
|
||||
- r->_socket = 0;
|
||||
+ r->_socket = -1;
|
||||
r->_axfr_soa_count = 0;
|
||||
r->_axfr_i = 0;
|
||||
r->_cur_axfr_pkt = NULL;
|
||||
@@ -903,6 +901,8 @@
|
||||
size_t i;
|
||||
|
||||
if (res) {
|
||||
+ close_socket(res->_socket);
|
||||
+
|
||||
if (res->_searchlist) {
|
||||
for (i = 0; i < ldns_resolver_searchlist_count(res); i++) {
|
||||
ldns_rdf_deep_free(res->_searchlist[i]);
|
||||
@@ -1198,7 +1198,7 @@
|
||||
ldns_status status;
|
||||
|
||||
/* check if start() has been called */
|
||||
- if (!resolver || resolver->_socket == 0) {
|
||||
+ if (!resolver || resolver->_socket == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1215,12 +1215,9 @@
|
||||
if (ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_SOA) {
|
||||
resolver->_axfr_soa_count++;
|
||||
if (resolver->_axfr_soa_count >= 2) {
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(resolver->_socket);
|
||||
-#else
|
||||
- closesocket(resolver->_socket);
|
||||
-#endif
|
||||
- resolver->_socket = 0;
|
||||
+
|
||||
+ close_socket(resolver->_socket);
|
||||
+
|
||||
ldns_pkt_free(resolver->_cur_axfr_pkt);
|
||||
resolver->_cur_axfr_pkt = NULL;
|
||||
}
|
||||
@@ -1243,12 +1240,8 @@
|
||||
/* RoRi: we must now also close the socket, otherwise subsequent uses of the
|
||||
same resolver structure will fail because the link is still open or
|
||||
in an undefined state */
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(resolver->_socket);
|
||||
-#else
|
||||
- closesocket(resolver->_socket);
|
||||
-#endif
|
||||
- resolver->_socket = 0;
|
||||
+
|
||||
+ close_socket(resolver->_socket);
|
||||
|
||||
return NULL;
|
||||
} else if (ldns_pkt_get_rcode(resolver->_cur_axfr_pkt) != 0) {
|
||||
@@ -1258,12 +1251,8 @@
|
||||
/* RoRi: we must now also close the socket, otherwise subsequent uses of the
|
||||
same resolver structure will fail because the link is still open or
|
||||
in an undefined state */
|
||||
-#ifndef USE_WINSOCK
|
||||
- close(resolver->_socket);
|
||||
-#else
|
||||
- closesocket(resolver->_socket);
|
||||
-#endif
|
||||
- resolver->_socket = 0;
|
||||
+
|
||||
+ close_socket(resolver->_socket);
|
||||
|
||||
return NULL;
|
||||
} else {
|
Loading…
Reference in New Issue