summaryrefslogtreecommitdiff
path: root/libc/misc/syslog/syslog.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-09-10 05:37:10 +0000
committerEric Andersen <andersen@codepoet.org>2002-09-10 05:37:10 +0000
commitbee4f83a21cf7ca9937f7c69020cd44e076c9591 (patch)
tree22e2b4028d4dcb505139ebc6a7933ee028fe8735 /libc/misc/syslog/syslog.c
parentf7edd11da97c5720590804f1642c4a7a8783436b (diff)
Patch from Tiago Marques <tmarques@viaconnect.inf.br> -- fall back to
using SOCK_STREAM if SOCK_DGRAM fails. -Erik
Diffstat (limited to 'libc/misc/syslog/syslog.c')
-rw-r--r--libc/misc/syslog/syslog.c15
1 files changed, 12 insertions, 3 deletions
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;
}