Patch by Felipe Kellermann, fix a bug introduced in the last patch by adding a condition around the remote logging, also adds some comments.

This commit is contained in:
Glenn L McGrath 2004-09-14 18:12:13 +00:00
parent d4004ee6a9
commit 73ebb889da

View File

@ -432,24 +432,30 @@ static void logMessage(int pri, char *msg)
/* todo: supress duplicates */ /* todo: supress duplicates */
#ifdef CONFIG_FEATURE_REMOTE_LOG #ifdef CONFIG_FEATURE_REMOTE_LOG
/* send message to remote logger */ if (doRemoteLog == TRUE) {
/* trying connect the socket */
if (-1 == remotefd) { if (-1 == remotefd) {
init_RemoteLog(); init_RemoteLog();
} }
/* if we have a valid socket, send the message */
if (-1 != remotefd) { if (-1 != remotefd) {
now = 1; now = 1;
snprintf(line, sizeof(line), "<%d> %s", pri, msg); snprintf(line, sizeof(line), "<%d> %s", pri, msg);
retry: retry:
/* send message to remote logger */
if(( -1 == sendto(remotefd, line, strlen(line), 0, if(( -1 == sendto(remotefd, line, strlen(line), 0,
(struct sockaddr *) &remoteaddr, (struct sockaddr *) &remoteaddr,
sizeof(remoteaddr))) && (errno == EINTR)) { sizeof(remoteaddr))) && (errno == EINTR)) {
/* sleep now seconds and retry (with now * 2) */
sleep(now); sleep(now);
now *= 2; now *= 2;
goto retry; goto retry;
} }
} }
}
if (local_logging == TRUE) if (local_logging == TRUE)
#endif #endif
{ {