busybox: Fixed remote logging bug in which starting syslog before the network (and...
[openwrt.git] / package / busybox / patches / 610-syslog-remote-retry-connection.patch
1 Index: busybox-1.16.1/sysklogd/syslogd.c
2 ===================================================================
3 --- busybox-1.16.1.orig/sysklogd/syslogd.c 2010-03-28 13:44:04.000000000 -0400
4 +++ busybox-1.16.1/sysklogd/syslogd.c 2010-06-17 21:48:11.000000000 -0400
5 @@ -555,6 +555,7 @@
6 static void do_syslogd(void)
7 {
8 int sock_fd;
9 + int send_err = 0;
10 #if ENABLE_FEATURE_SYSLOGD_DUP
11 int last_sz = -1;
12 char *last_buf;
13 @@ -632,10 +633,23 @@
14 * over network, mimic that */
15 recvbuf[sz] = '\n';
16 /* send message to remote logger, ignore possible error */
17 - /* TODO: on some errors, close and set G.remoteFD to -1
18 - * so that DNS resolution and connect is retried? */
19 - sendto(G.remoteFD, recvbuf, sz+1, MSG_DONTWAIT,
20 - &G.remoteAddr->u.sa, G.remoteAddr->len);
21 + if ( sendto(G.remoteFD, recvbuf, sz+1, MSG_DONTWAIT,
22 + &G.remoteAddr->u.sa, G.remoteAddr->len) == -1 ) {
23 + send_err = errno;
24 + }
25 +
26 + /* On some errors, close and set G.remoteFD to -1
27 + * so that DNS resolution and connect is retried */
28 + switch (send_err) {
29 + case ECONNRESET:
30 + case EDESTADDRREQ:
31 + case EISCONN:
32 + case ENOTCONN:
33 + case EPIPE:
34 + close(G.remoteFD);
35 + G.remoteFD = -1;
36 + break;
37 + }
38 no_luck: ;
39 }
40 #endif
This page took 0.044566 seconds and 5 git commands to generate.