148f15720a5bb37f3090e8ba2f2079cceefc4057
[openwrt/staging/dangole.git] /
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.
5
6 http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2019q1/012953.html
7 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
8 ---
9 src/dnsmasq.c | 23 +++++++++++------------
10 1 file changed, 11 insertions(+), 12 deletions(-)
11
12 --- a/src/dnsmasq.c
13 +++ b/src/dnsmasq.c
14 @@ -552,7 +552,7 @@ int main (int argc, char **argv)
15 char *msg;
16
17 /* close our copy of write-end */
18 - while (retry_send(close(err_pipe[1])));
19 + close(err_pipe[1]);
20
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)
24 _exit(EC_GOOD);
25 }
26
27 - while (retry_send(close(err_pipe[0])));
28 + close(err_pipe[0]);
29
30 /* NO calls to die() from here on. */
31
32 @@ -623,8 +623,7 @@ int main (int argc, char **argv)
33 err = 1;
34 else
35 {
36 - while (retry_send(close(fd)));
37 - if (errno != 0)
38 + if (close(fd) == -1)
39 err = 1;
40 }
41 }
42 @@ -957,7 +956,7 @@ int main (int argc, char **argv)
43
44 /* finished start-up - release original process */
45 if (err_pipe[1] != -1)
46 - while (retry_send(close(err_pipe[1])));
47 + close(err_pipe[1]);
48
49 if (daemon->port != 0)
50 check_servers();
51 @@ -1483,7 +1482,7 @@ static void async_event(int pipe, time_t
52 do {
53 helper_write();
54 } while (!helper_buf_empty() || do_script_run(now));
55 - while (retry_send(close(daemon->helperfd)));
56 + close(daemon->helperfd);
57 }
58 #endif
59
60 @@ -1728,7 +1727,7 @@ static void check_dns_listeners(time_t n
61
62 if (getsockname(confd, (struct sockaddr *)&tcp_addr, &tcp_len) == -1)
63 {
64 - while (retry_send(close(confd)));
65 + close(confd);
66 continue;
67 }
68
69 @@ -1793,7 +1792,7 @@ static void check_dns_listeners(time_t n
70 if (!client_ok)
71 {
72 shutdown(confd, SHUT_RDWR);
73 - while (retry_send(close(confd)));
74 + close(confd);
75 }
76 else if (!option_bool(OPT_DEBUG) && pipe(pipefd) == 0 && (p = fork()) != 0)
77 {
78 @@ -1812,7 +1811,7 @@ static void check_dns_listeners(time_t n
79 break;
80 }
81 }
82 - while (retry_send(close(confd)));
83 + close(confd);
84
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);
89
90 shutdown(confd, SHUT_RDWR);
91 - while (retry_send(close(confd)));
92 + close(confd);
93
94 if (buff)
95 free(buff);
96 @@ -1867,7 +1866,7 @@ static void check_dns_listeners(time_t n
97 if (s->tcpfd != -1)
98 {
99 shutdown(s->tcpfd, SHUT_RDWR);
100 - while (retry_send(close(s->tcpfd)));
101 + close(s->tcpfd);
102 }
103 if (!option_bool(OPT_DEBUG))
104 {
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);
107
108 #if defined(HAVE_LINUX_NETWORK) || defined(HAVE_SOLARIS_NETWORK)
109 - while (retry_send(close(fd)));
110 + close(fd);
111 #else
112 opt = 1;
113 setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt));