Last rename + explicit EMFILE check replacement

This commit is contained in:
Willem Toorop 2017-11-03 16:42:38 +01:00
parent 9b019b8c6e
commit 439f41149b
5 changed files with 14 additions and 14 deletions

View File

@ -1199,7 +1199,7 @@ static void tas_read_cb(void *userarg)
return;
}
}
} else if (_getdns_socket_wants_retry())
} else if (_getdns_socketerror_wants_retry())
return;
DEBUG_ANCHOR("Read error: %d %s\n", (int)n, _getdns_errnostr());
@ -1249,7 +1249,7 @@ static void tas_write_cb(void *userarg)
tas_read_cb, NULL, tas_timeout_cb));
return;
} else if (_getdns_socket_wants_retry())
} else if (_getdns_socketerror_wants_retry())
return;
DEBUG_ANCHOR("Write error: %s\n", _getdns_errnostr());

View File

@ -245,7 +245,7 @@ select_eventloop_run_once(getdns_eventloop *loop, int blocking)
#endif
if (select(max_fd + 1, &readfds, &writefds, NULL,
(timeout == TIMEOUT_FOREVER ? NULL : &tv)) < 0) {
if (_getdns_socket_wants_retry())
if (_getdns_socketerror_wants_retry())
return;
DEBUG_SCHED("I/O error with select(): %s\n", _getdns_errnostr());

View File

@ -143,7 +143,7 @@ void _getdns_perror(const char *str);
|| (X) == _getdns_EWOULDBLOCK \
|| (X) == _getdns_EINPROGRESS \
|| (X) == _getdns_ENOBUFS ))
#define _getdns_socket_wants_retry() (_getdns_error_wants_retry(_getdns_socketerror()))
#define _getdns_socketerror_wants_retry() (_getdns_error_wants_retry(_getdns_socketerror()))
#define _getdns_resource_depletion() ( _getdns_socketerror() != 0 \
&& ( _getdns_socketerror() == _getdns_ENFILE \
|| _getdns_socketerror() == _getdns_EMFILE ))

View File

@ -191,7 +191,7 @@ static void tcp_write_cb(void *userarg)
(const void *)&to_write->write_buf[to_write->written],
to_write->write_buf_len - to_write->written, 0)) == -1) {
if (_getdns_socket_wants_retry())
if (_getdns_socketerror_wants_retry())
return;
DEBUG_SERVER("I/O error from send(): %s\n",
@ -287,7 +287,7 @@ getdns_reply(
if (conn->l->fd >= 0 && sendto(conn->l->fd, (void *)buf, len, 0,
(struct sockaddr *)&conn->remote_in, conn->addrlen) == -1) {
/* TODO: handle _getdns_socket_wants_retry() */
/* TODO: handle _getdns_socketerror_wants_retry() */
/* IO error, never cleanup a listener because of I/O error */
DEBUG_SERVER("I/O error from sendto(): %s\n",
@ -371,7 +371,7 @@ static void tcp_read_cb(void *userarg)
if ((bytes_read = recv(conn->fd,
(void *)conn->read_pos, conn->to_read, 0)) < 0) {
if (_getdns_socket_wants_retry())
if (_getdns_socketerror_wants_retry())
return; /* Come back to do the read later */
/* IO error, close connection */
@ -486,7 +486,7 @@ static void tcp_accept_cb(void *userarg)
if ((conn->fd = accept(l->fd, (struct sockaddr *)
&conn->super.remote_in, &conn->super.addrlen)) == -1) {
if (_getdns_socket_wants_retry() ||
if (_getdns_socketerror_wants_retry() ||
_getdns_socketerror() == _getdns_ECONNRESET)
; /* pass */
@ -564,7 +564,7 @@ static void udp_read_cb(void *userarg)
conn->addrlen = sizeof(conn->remote_in);
if ((len = recvfrom(l->fd, (void *)buf, sizeof(buf), 0,
(struct sockaddr *)&conn->remote_in, &conn->addrlen)) == -1) {
if ( _getdns_socket_wants_retry() &&
if ( _getdns_socketerror_wants_retry() &&
_getdns_socketerror() != _getdns_ECONNRESET) {
/*
* WINSOCK gives ECONNRESET on ICMP Port Unreachable

View File

@ -638,7 +638,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf)
}
read = recv(fd, (void *)tcp->read_pos, tcp->to_read, 0);
if (read < 0) {
if (_getdns_socket_wants_retry())
if (_getdns_socketerror_wants_retry())
return STUB_TCP_RETRY;
else
return STUB_TCP_ERROR;
@ -756,7 +756,7 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
(struct sockaddr *)&(netreq->upstream->addr),
netreq->upstream->addr_len);
#endif
if ((written == -1 && _getdns_socket_wants_retry()) ||
if ((written == -1 && _getdns_socketerror_wants_retry()) ||
(size_t)written < pkt_len + 2) {
/* We couldn't write the whole packet.
@ -788,7 +788,7 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
written = send(fd, (void *)(tcp->write_buf + tcp->written),
tcp->write_buf_len - tcp->written, 0);
if (written == -1) {
if (_getdns_socket_wants_retry())
if (_getdns_socketerror_wants_retry())
return STUB_TCP_RETRY;
else {
DEBUG_STUB("%s %-35s: MSG: %p error while writing to TCP socket:"
@ -1331,7 +1331,7 @@ stub_udp_read_cb(void *userarg)
* i.e. overflow
*/
0, NULL, NULL);
if (read == -1 && (_getdns_socket_wants_retry() ||
if (read == -1 && (_getdns_socketerror_wants_retry() ||
_getdns_socketerror() == _getdns_ECONNRESET))
return; /* Try again later */
@ -2060,7 +2060,7 @@ upstream_find_for_netreq(getdns_network_req *netreq)
continue;
if (fd == -1) {
if (_getdns_socketerror() == _getdns_EMFILE)
if (_getdns_resource_depletion())
return STUB_TRY_AGAIN_LATER;
return -1;
}