[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH]: Syslog remote logging fails if network not available on
From:       Daniel Dickinson <cshore () csolve ! net>
Date:       2010-06-27 13:05:32
Message-ID: 1277643932.5373.8.camel () daniloth ! fionavar ! dd
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


The attached patch fixes a bug (or missing feature) in busybox's syslog
implementation.  The current implementation only makes one connection
attempt to the remote host, so that if the network or host is
unavailable when syslog first makes an attempt to send a messages to the
remote host messages are never sent.

The attached patch considers certain failures when attempt to transmit a
log message, (ECONNRESET, EDESTADDRREQ, EISCONN, ENOTCONN, EPIPE) as
cause to close and remove the connection socket so that on the next
syslog message to be sent, another connection will be tried.

Signed-Off-By: Daniel Dickinson <cshore@csolve.net>
-- 
And that's my crabbing done for the day.  Got it out of the way early, 
now I have the rest of the afternoon to sniff fragrant tea-roses or 
strangle cute bunnies or something.   -- Michael Devore
GnuPG Key Fingerprint 86 F5 81 A5 D4 2E 1F 1C      http://gnupg.org
The C Shore (Daniel Dickinson's Website) http://cshore.is-a-geek.com


["syslog-remote-retry.patch" (syslog-remote-retry.patch)]

diff -Naur busybox-1.16.2.orig/sysklogd/syslogd.c busybox-1.16.2/sysklogd/syslogd.c
--- busybox-1.16.2.orig/sysklogd/syslogd.c	2010-06-12 09:50:08.000000000 -0400
+++ busybox-1.16.2/sysklogd/syslogd.c	2010-06-27 08:23:15.000000000 -0400
@@ -555,6 +555,7 @@
 static void do_syslogd(void)
 {
 	int sock_fd;
+	int send_err = 0;
 #if ENABLE_FEATURE_SYSLOGD_DUP
 	int last_sz = -1;
 	char *last_buf;
@@ -632,10 +633,23 @@
 			 * over network, mimic that */
 			recvbuf[sz] = '\n';
 			/* send message to remote logger, ignore possible error */
-			/* TODO: on some errors, close and set G.remoteFD to -1
-			 * so that DNS resolution and connect is retried? */
-			sendto(G.remoteFD, recvbuf, sz+1, MSG_DONTWAIT,
-				    &G.remoteAddr->u.sa, G.remoteAddr->len);
+			if ( sendto(G.remoteFD, recvbuf, sz+1, MSG_DONTWAIT,
+				    &G.remoteAddr->u.sa, G.remoteAddr->len)  == -1 ) {
+				send_err = errno;
+		    }
+
+			/* On some errors, close and set G.remoteFD to -1
+			 * so that DNS resolution and connect is retried */
+		    switch (send_err) {
+			case ECONNRESET:
+			case EDESTADDRREQ:
+			case EISCONN:
+			case ENOTCONN:
+			case EPIPE:
+					close(G.remoteFD);
+					G.remoteFD = -1;
+					break;
+		    }
  no_luck: ;
 		}
 #endif

["signature.asc" (application/pgp-signature)]

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic