aboutsummaryrefslogtreecommitdiff
path: root/sysklogd
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-08-26 23:15:29 +0000
committerEric Andersen <andersen@codepoet.org>2004-08-26 23:15:29 +0000
commit75813eea230ccf60ac8623ffb161c890c6f063c5 (patch)
tree76a4f528f98381a03778e5e7b00515a8063b295e /sysklogd
parent138791050d36d221d718568094892245d7c6f6ec (diff)
downloadbusybox-75813eea230ccf60ac8623ffb161c890c6f063c5.tar.gz
Togg writes:
Syslogd wont start if remote-logging is enabled and the connection to the remote-log server is not possible on syslogd startup. I found a patch somewhere which works like a charm. It uses sendto() which seems more reliable for this issue. Please see attached patch. Many people will be more happy with this included I think. Regards, Togg
Diffstat (limited to 'sysklogd')
-rw-r--r--sysklogd/syslogd.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 2023873a8..741c80673 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -78,6 +78,8 @@ static char LocalHostName[64];
#include <netinet/in.h>
/* udp socket for logging to remote host */
static int remotefd = -1;
+static struct sockaddr_in remoteaddr;
+static int remoteaddrlen;
/* where do we log? */
static char *RemoteHost;
@@ -384,6 +386,7 @@ static void logMessage(int pri, char *msg)
time_t now;
char *timestamp;
static char res[20] = "";
+ static char line[512];
CODE *c_pri, *c_fac;
if (pri != 0) {
@@ -414,21 +417,15 @@ static void logMessage(int pri, char *msg)
#ifdef CONFIG_FEATURE_REMOTE_LOG
/* send message to remote logger */
if (-1 != remotefd) {
- static const int IOV_COUNT = 2;
- struct iovec iov[IOV_COUNT];
- struct iovec *v = iov;
-
- memset(&res, 0, sizeof(res));
- snprintf(res, sizeof(res), "<%d>", pri);
- v->iov_base = res;
- v->iov_len = strlen(res);
- v++;
-
- v->iov_base = msg;
- v->iov_len = strlen(msg);
- writev_retry:
- if ((-1 == writev(remotefd, iov, IOV_COUNT)) && (errno == EINTR)) {
- goto writev_retry;
+
+ memset(&line, 0, sizeof(line));
+ snprintf(line, sizeof(line), "<%d> <%s>", pri, msg);
+
+ retry:
+ if(( -1 == sendto(remotefd, line, strlen(line), 0,
+ (struct sockaddr *) &remoteaddr,
+ remoteaddrlen)) && (errno == EINTR)) {
+ goto retry;
}
}
if (local_logging == TRUE)
@@ -508,12 +505,10 @@ static int serveConnection(char *tmpbuf, int n_read)
#ifdef CONFIG_FEATURE_REMOTE_LOG
static void init_RemoteLog(void)
{
-
- struct sockaddr_in remoteaddr;
struct hostent *hostinfo;
- int len = sizeof(remoteaddr);
+ remoteaddrlen = sizeof(remoteaddr);
- memset(&remoteaddr, 0, len);
+ memset(&remoteaddr, 0, remoteaddrlen);
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
@@ -526,15 +521,6 @@ static void init_RemoteLog(void)
remoteaddr.sin_family = AF_INET;
remoteaddr.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
remoteaddr.sin_port = htons(RemotePort);
-
- /* Since we are using UDP sockets, connect just sets the default host and port
- * for future operations
- */
- if (0 != (connect(remotefd, (struct sockaddr *) &remoteaddr, len))) {
- bb_error_msg_and_die("cannot connect to remote host %s:%d", RemoteHost,
- RemotePort);
- }
-
}
#endif