aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2004-09-14 18:12:13 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2004-09-14 18:12:13 +0000
commit73ebb889daf30980bddc3d3065ff10844c4624dc (patch)
treeb99647c7f1dc979ff0cdc77a8ec0a3feeccaf29f
parentd4004ee6a933eaf3d3843624d8c63e922db8d7dd (diff)
downloadbusybox-73ebb889daf30980bddc3d3065ff10844c4624dc.tar.gz
Patch by Felipe Kellermann, fix a bug introduced in the last patch by adding a condition around the remote logging, also adds some comments.
-rw-r--r--sysklogd/syslogd.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index ef9cf2162..8c6c44ee0 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -432,24 +432,30 @@ static void logMessage(int pri, char *msg)
/* todo: supress duplicates */
#ifdef CONFIG_FEATURE_REMOTE_LOG
- /* send message to remote logger */
- if (-1 == remotefd) {
- init_RemoteLog();
- }
+ if (doRemoteLog == TRUE) {
+ /* trying connect the socket */
+ if (-1 == remotefd) {
+ init_RemoteLog();
+ }
- if (-1 != remotefd) {
- now = 1;
- snprintf(line, sizeof(line), "<%d> %s", pri, msg);
-
- retry:
- if(( -1 == sendto(remotefd, line, strlen(line), 0,
- (struct sockaddr *) &remoteaddr,
- sizeof(remoteaddr))) && (errno == EINTR)) {
- sleep(now);
- now *= 2;
- goto retry;
+ /* if we have a valid socket, send the message */
+ if (-1 != remotefd) {
+ now = 1;
+ snprintf(line, sizeof(line), "<%d> %s", pri, msg);
+
+ retry:
+ /* send message to remote logger */
+ if(( -1 == sendto(remotefd, line, strlen(line), 0,
+ (struct sockaddr *) &remoteaddr,
+ sizeof(remoteaddr))) && (errno == EINTR)) {
+ /* sleep now seconds and retry (with now * 2) */
+ sleep(now);
+ now *= 2;
+ goto retry;
+ }
}
}
+
if (local_logging == TRUE)
#endif
{