1 From 5fc639cf9a9aafd3a2b50570808a74a4ee5cd12a Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Fri, 29 Mar 2019 21:29:43 +0000
4 Subject: [PATCH 50/57] Don't retry close() syscalls after an EINTR errors.
6 http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2019q1/012953.html
7 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
9 src/dnsmasq.c | 23 +++++++++++------------
10 1 file changed, 11 insertions(+), 12 deletions(-)
14 @@ -552,7 +552,7 @@ int main (int argc, char **argv)
17 /* close our copy of write-end */
18 - while (retry_send(close(err_pipe[1])));
21 /* check for errors after the fork */
22 if (read_event(err_pipe[0], &ev, &msg))
23 @@ -561,7 +561,7 @@ int main (int argc, char **argv)
27 - while (retry_send(close(err_pipe[0])));
30 /* NO calls to die() from here on. */
32 @@ -623,8 +623,7 @@ int main (int argc, char **argv)
36 - while (retry_send(close(fd)));
38 + if (close(fd) == -1)
42 @@ -957,7 +956,7 @@ int main (int argc, char **argv)
44 /* finished start-up - release original process */
45 if (err_pipe[1] != -1)
46 - while (retry_send(close(err_pipe[1])));
49 if (daemon->port != 0)
51 @@ -1483,7 +1482,7 @@ static void async_event(int pipe, time_t
54 } while (!helper_buf_empty() || do_script_run(now));
55 - while (retry_send(close(daemon->helperfd)));
56 + close(daemon->helperfd);
60 @@ -1728,7 +1727,7 @@ static void check_dns_listeners(time_t n
62 if (getsockname(confd, (struct sockaddr *)&tcp_addr, &tcp_len) == -1)
64 - while (retry_send(close(confd)));
69 @@ -1793,7 +1792,7 @@ static void check_dns_listeners(time_t n
72 shutdown(confd, SHUT_RDWR);
73 - while (retry_send(close(confd)));
76 else if (!option_bool(OPT_DEBUG) && pipe(pipefd) == 0 && (p = fork()) != 0)
78 @@ -1812,7 +1811,7 @@ static void check_dns_listeners(time_t n
82 - while (retry_send(close(confd)));
85 /* The child can use up to TCP_MAX_QUERIES ids, so skip that many. */
86 daemon->log_id += TCP_MAX_QUERIES;
87 @@ -1858,7 +1857,7 @@ static void check_dns_listeners(time_t n
88 buff = tcp_request(confd, now, &tcp_addr, netmask, auth_dns);
90 shutdown(confd, SHUT_RDWR);
91 - while (retry_send(close(confd)));
96 @@ -1867,7 +1866,7 @@ static void check_dns_listeners(time_t n
99 shutdown(s->tcpfd, SHUT_RDWR);
100 - while (retry_send(close(s->tcpfd)));
103 if (!option_bool(OPT_DEBUG))
105 @@ -1943,7 +1942,7 @@ int icmp_ping(struct in_addr addr)
106 gotreply = delay_dhcp(dnsmasq_time(), PING_WAIT, fd, addr.s_addr, id);
108 #if defined(HAVE_LINUX_NETWORK) || defined(HAVE_SOLARIS_NETWORK)
109 - while (retry_send(close(fd)));
113 setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt));