--------------------- PatchSet 11714 Date: 2007/10/02 01:03:53 Author: hno Branch: SQUID_2_6 Tag: (none) Log: MFC: Move logopen() much earlier to have fatal startup errors sent to the proper syslog facility Members: src/debug.c:1.93->1.93.2.1 src/globals.h:1.123->1.123.2.1 src/main.c:1.393.2.4->1.393.2.5 Index: squid/src/debug.c =================================================================== RCS file: /cvsroot/squid/squid/src/debug.c,v retrieving revision 1.93 retrieving revision 1.93.2.1 diff -u -r1.93 -r1.93.2.1 --- squid/src/debug.c 9 Sep 2006 12:45:06 -0000 1.93 +++ squid/src/debug.c 2 Oct 2007 01:03:53 -0000 1.93.2.1 @@ -1,6 +1,6 @@ /* - * $Id: debug.c,v 1.93 2006/09/09 12:45:06 serassio Exp $ + * $Id: debug.c,v 1.93.2.1 2007/10/02 01:03:53 hno Exp $ * * DEBUG: section 0 Debug Routines * AUTHOR: Harvest Derived @@ -40,9 +40,6 @@ static const char *debugLogTime(time_t); static void ctx_print(void); #if HAVE_SYSLOG -#ifdef LOG_LOCAL4 -static int syslog_facility = 0; -#endif static void _db_print_syslog(const char *format, va_list args); #endif static void _db_print_stderr(const char *format, va_list args); @@ -186,7 +183,7 @@ tmpbuf[0] = '\0'; vsnprintf(tmpbuf, BUFSIZ, format, args); tmpbuf[BUFSIZ - 1] = '\0'; - syslog(_db_level == 0 ? LOG_WARNING : LOG_NOTICE, "%s", tmpbuf); + syslog((_db_level == 0 ? LOG_WARNING : LOG_NOTICE) | syslog_facility, "%s", tmpbuf); } #endif /* HAVE_SYSLOG */ @@ -401,12 +398,6 @@ xfree(p); } debugOpenLog(logfile); - -#if HAVE_SYSLOG && defined(LOG_LOCAL4) - if (opt_syslog_enable) - openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, syslog_facility); -#endif /* HAVE_SYSLOG */ - } void Index: squid/src/globals.h =================================================================== RCS file: /cvsroot/squid/squid/src/globals.h,v retrieving revision 1.123 retrieving revision 1.123.2.1 diff -u -r1.123 -r1.123.2.1 --- squid/src/globals.h 19 Jan 2007 00:19:26 -0000 1.123 +++ squid/src/globals.h 2 Oct 2007 01:03:53 -0000 1.123.2.1 @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.123 2007/01/19 00:19:26 hno Exp $ + * $Id: globals.h,v 1.123.2.1 2007/10/02 01:03:53 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -178,5 +178,8 @@ #endif extern int opt_parse_cfg_only; /* 0 */ extern int n_coss_dirs; /* 0 */ +#ifdef LOG_LOCAL4 +extern int syslog_facility; /* LOG_LOCAL4 */ +#endif #endif /* SQUID_GLOBALS_H */ Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid/squid/src/main.c,v retrieving revision 1.393.2.4 retrieving revision 1.393.2.5 diff -u -r1.393.2.4 -r1.393.2.5 --- squid/src/main.c 31 Aug 2007 13:52:10 -0000 1.393.2.4 +++ squid/src/main.c 2 Oct 2007 01:03:53 -0000 1.393.2.5 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.393.2.4 2007/08/31 13:52:10 hno Exp $ + * $Id: main.c,v 1.393.2.5 2007/10/02 01:03:53 hno Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -710,6 +710,8 @@ #endif mainParseOptions(argc, argv); + openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, syslog_facility); + #if defined(USE_WIN32_SERVICE) && defined(_SQUID_WIN32_) if (opt_install_service) { WIN32_InstallService(); @@ -972,14 +974,12 @@ int nullfd; if (*(argv[0]) == '(') return; - openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4); if ((pid = fork()) < 0) syslog(LOG_ALERT, "fork failed: %s", xstrerror()); else if (pid > 0) exit(0); if (setsid() < 0) syslog(LOG_ALERT, "setsid failed: %s", xstrerror()); - closelog(); #ifdef TIOCNOTTY if ((i = open("/dev/tty", O_RDWR | O_TEXT)) >= 0) { ioctl(i, TIOCNOTTY, NULL); @@ -1008,7 +1008,6 @@ mainStartScript(argv[0]); if ((pid = fork()) == 0) { /* child */ - openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4); prog = xstrdup(argv[0]); argv[0] = xstrdup("(squid)"); execvp(prog, argv); @@ -1016,7 +1015,6 @@ exit(1); } /* parent */ - openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4); syslog(LOG_NOTICE, "Squid Parent: child process %d started", pid); time(&start); squid_signal(SIGINT, SIG_IGN, SA_RESTART);