--- glibc-2.1.3/misc/syslog.c.ORG Thu Feb 20 14:54:24 2003 +++ glibc-2.1.3/misc/syslog.c Thu Feb 20 15:15:58 2003 @@ -63,6 +63,17 @@ # define ftell(s) _IO_ftell (s) #endif +#define SINA_SYSLOG_CORRECT_DGRAM 1 +#define SINA_SYSLOG_SUPPORT_ASYNC 1 + +#ifdef SINA_SYSLOG_CORRECT_DGRAM +static char sinaoptions[] = "SINA_SYSLOG_CORRECT_DGRAM"; +#endif /* SINA_SYSLOG_CORRECT_DGRAM */ +#ifdef SINA_SYSLOG_SUPPORT_ASYNC +static char sinaoptions1[] = "SINA_SYSLOG_SUPPORT_ASYNC"; +#define SINASYSLOGASYNC "SINASYSLOGASYNC" +#endif /* SINA_SYSLOG_SUPPORT_ASYNC */ + static int LogType = SOCK_DGRAM; /* type of socket connection */ static int LogFile = -1; /* fd for log */ static int connected; /* have done connect */ @@ -124,6 +135,9 @@ struct sigaction *oldaction_ptr = NULL; int sigpipe; int saved_errno = errno; +#ifdef SINA_SYSLOG_SUPPORT_ASYNC + int send_flags = 0; +#endif #define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID /* Check for invalid bits. */ @@ -214,7 +228,13 @@ if (LogType == SOCK_STREAM) ++bufsize; +#ifdef SINA_SYSLOG_SUPPORT_ASYNC + if (getenv(SINASYSLOGASYNC)) send_flags = MSG_DONTWAIT; + if (!connected || __send(LogFile, buf, bufsize, send_flags) < 0) +#else if (!connected || __send(LogFile, buf, bufsize, 0) < 0) +#endif /* SINA_SYSLOG_SUPPORT_ASYNC */ + { closelog_internal (); /* attempt re-open next time */ /* @@ -276,8 +296,15 @@ if (LogType == SOCK_DGRAM && saved_errno == EPROTOTYPE) { + +#ifdef SINA_SYSLOG_CORRECT_DGRAM + /* NO NO NO retry with next SOCK_STREAM: */ + LogType = SOCK_DGRAM; +#else /* retry with next SOCK_STREAM: */ LogType = SOCK_STREAM; +#endif /* SINA_SYSLOG_CORRECT_DGRAM */ + __set_errno (old_errno); continue; }