From bee4f83a21cf7ca9937f7c69020cd44e076c9591 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 10 Sep 2002 05:37:10 +0000 Subject: Patch from Tiago Marques -- fall back to using SOCK_STREAM if SOCK_DGRAM fails. -Erik --- libc/misc/syslog/syslog.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'libc/misc/syslog') diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c index 531438b54..2320caf25 100644 --- a/libc/misc/syslog/syslog.c +++ b/libc/misc/syslog/syslog.c @@ -264,6 +264,8 @@ getout: void openlog( const char *ident, int logstat, int logfac ) { + int logType = SOCK_DGRAM; + LOCK; if (ident != NULL) @@ -275,8 +277,9 @@ openlog( const char *ident, int logstat, int logfac ) SyslogAddr.sa_family = AF_UNIX; (void)strncpy(SyslogAddr.sa_data, _PATH_LOG, sizeof(SyslogAddr.sa_data)); +retry: if (LogStat & LOG_NDELAY) { - if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1){ + if ((LogFile = socket(AF_UNIX, logType, 0)) == -1){ UNLOCK; return; } @@ -286,13 +289,19 @@ openlog( const char *ident, int logstat, int logfac ) if (LogFile != -1 && !connected && #if 0 connect(LogFile, &SyslogAddr, sizeof(SyslogAddr.sa_family)+ - strlen(SyslogAddr.sa_data)) != -1) + strlen(SyslogAddr.sa_data)) != -1 #else connect(LogFile, &SyslogAddr, sizeof(SyslogAddr) - sizeof(SyslogAddr.sa_data) + - strlen(SyslogAddr.sa_data)) != -1) + strlen(SyslogAddr.sa_data)) != -1 #endif + ) + { connected = 1; + } else if (logType == SOCK_DGRAM) { + logType = SOCK_STREAM; + goto retry; + } UNLOCK; } -- cgit v1.2.3