X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=errlog.c;h=2ec5a808bd2859d2d3119066d3714871791a57e7;hb=290379eb090961676eec6dc842338c5059fa3213;hp=7ffc7d15b0e80f91b655b34bdada4db34fa21bb1;hpb=21b1aa1e2548be610737df323e06f2751358678d;p=privoxy.git diff --git a/errlog.c b/errlog.c index 7ffc7d15..2ec5a808 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.93 2009/05/16 13:27:20 fabiankeil Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.101 2010/06/13 12:24:49 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -316,7 +316,7 @@ void init_error_log(const char *prog_name, const char *logfname) * Currently we reopen it every time the config file * has been reloaded, but actually we only have to * reopen it if the file name changed or if the - * configuration reloas was caused by a SIGHUP. + * configuration reload was caused by a SIGHUP. */ log_error(LOG_LEVEL_INFO, "Failed to reopen logfile: \'%s\'. " "Retrying after closing the old file descriptor first. If that " @@ -342,6 +342,21 @@ void init_error_log(const char *prog_name, const char *logfname) { fclose(logfp); } +#ifdef unix + if (daemon_mode && (logfp == stderr)) + { + if (dup2(1, 2) == -1) + { + /* + * We only use fatal_error() to clear the pid + * file and to exit. Given that stderr has just + * been closed, the user will not see the error + * message. + */ + fatal_error("Failed to reserve fd 2."); + } + } +#endif logfp = fp; unlock_logfile(); @@ -422,12 +437,11 @@ static inline size_t get_log_timestamp(char *buffer, size_t buffer_size) gettimeofday(&tv_now, NULL); msecs = tv_now.tv_usec / 1000; - - time(&now); + now = tv_now.tv_sec; #ifdef HAVE_LOCALTIME_R tm_now = *localtime_r(&now, &tm_now); -#elif FEATURE_PTHREAD +#elif defined(MUTEX_LOCKS_AVAILABLE) privoxy_mutex_lock(&localtime_mutex); tm_now = *localtime(&now); privoxy_mutex_unlock(&localtime_mutex); @@ -485,7 +499,7 @@ static inline size_t get_clf_timestamp(char *buffer, size_t buffer_size) time (&now); #ifdef HAVE_GMTIME_R gmt = *gmtime_r(&now, &gmt); -#elif FEATURE_PTHREAD +#elif defined(MUTEX_LOCKS_AVAILABLE) privoxy_mutex_lock(&gmtime_mutex); gmt = *gmtime(&now); privoxy_mutex_unlock(&gmtime_mutex); @@ -494,7 +508,7 @@ static inline size_t get_clf_timestamp(char *buffer, size_t buffer_size) #endif #ifdef HAVE_LOCALTIME_R tm_now = localtime_r(&now, &dummy); -#elif FEATURE_PTHREAD +#elif defined(MUTEX_LOCKS_AVAILABLE) privoxy_mutex_lock(&localtime_mutex); tm_now = localtime(&now); privoxy_mutex_unlock(&localtime_mutex); @@ -574,11 +588,9 @@ static inline const char *get_log_level_string(int loglevel) log_level_string = "Force"; break; #endif /* def FEATURE_FORCE_LOAD */ -#ifdef FEATURE_FAST_REDIRECTS case LOG_LEVEL_REDIRECTS: log_level_string = "Redirect"; break; -#endif /* def FEATURE_FAST_REDIRECTS */ case LOG_LEVEL_DEANIMATE: log_level_string = "Gif-Deanimate"; break; @@ -938,14 +950,14 @@ void log_error(int loglevel, const char *fmt, ...) * visible to all files that include errlog.h. * * Parameters : - * 1 : error = a valid jb_err code + * 1 : jb_error = a valid jb_err code * * Returns : A string with the jb_err translation * *********************************************************************/ -const char *jb_err_to_string(int error) +const char *jb_err_to_string(int jb_error) { - switch (error) + switch (jb_error) { case JB_ERR_OK: return "Success, no error";