From 92b3f9f61301728983a79cb367a85b00a3439e16 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Thu, 28 May 2009 17:07:42 +0000 Subject: [PATCH] Check the right macro to decide if we can use privoxy_mutex_lock(). Should fix the crash-while-randomizing-header-dates bug on mingw32 anonymously reported in #2797798. This is pretty much the same bug that was already fixed in 3.0.7, but apparently I found a way to reintroduce it in 3.0.11. Yeehaw. --- cgi.c | 14 +++++++------- errlog.c | 8 ++++---- jbsockets.c | 10 ++++------ parsers.c | 8 ++++---- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/cgi.c b/cgi.c index efff693c..d0c224d4 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.116 2009/03/15 14:59:34 fabiankeil Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.117 2009/05/16 13:27:20 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -62,12 +62,12 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.116 2009/03/15 14:59:34 fabiankeil Exp $" #if defined(FEATURE_CGI_EDIT_ACTIONS) || defined(FEATURE_TOGGLE) #include "cgiedit.h" #endif /* defined(FEATURE_CGI_EDIT_ACTIONS) || defined (FEATURE_TOGGLE) */ -#include "loadcfg.h" + /* loadcfg.h is for global_toggle_state only */ -#ifdef FEATURE_PTHREAD -#include "jcc.h" +#include "loadcfg.h" /* jcc.h is for mutex semaphore globals only */ -#endif /* def FEATURE_PTHREAD */ +#include "jcc.h" + const char cgi_h_rcs[] = CGI_H_VERSION; /* @@ -1409,7 +1409,7 @@ void get_http_time(int time_offset, char *buf, size_t buffer_size) /* get and save the gmt */ #if HAVE_GMTIME_R t = gmtime_r(¤t_time, &dummy); -#elif FEATURE_PTHREAD +#elif def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&gmtime_mutex); t = gmtime(¤t_time); privoxy_mutex_unlock(&gmtime_mutex); @@ -1465,7 +1465,7 @@ static void get_locale_time(char *buf, size_t buffer_size) #if HAVE_LOCALTIME_R timeptr = localtime_r(¤t_time, &dummy); -#elif FEATURE_PTHREAD +#elif def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&localtime_mutex); timeptr = localtime(¤t_time); privoxy_mutex_unlock(&localtime_mutex); diff --git a/errlog.c b/errlog.c index 7ffc7d15..ea3ad104 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.94 2009/05/19 17:47:22 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -427,7 +427,7 @@ static inline size_t get_log_timestamp(char *buffer, size_t buffer_size) #ifdef HAVE_LOCALTIME_R tm_now = *localtime_r(&now, &tm_now); -#elif FEATURE_PTHREAD +#elif def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&localtime_mutex); tm_now = *localtime(&now); privoxy_mutex_unlock(&localtime_mutex); @@ -485,7 +485,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 def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&gmtime_mutex); gmt = *gmtime(&now); privoxy_mutex_unlock(&gmtime_mutex); @@ -494,7 +494,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 def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&localtime_mutex); tm_now = localtime(&now); privoxy_mutex_unlock(&localtime_mutex); diff --git a/jbsockets.c b/jbsockets.c index 57e9f1ac..11337087 100644 --- a/jbsockets.c +++ b/jbsockets.c @@ -1,4 +1,4 @@ -const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.58 2009/05/19 17:20:35 fabiankeil Exp $"; +const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.59 2009/05/25 15:43:34 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $ @@ -95,10 +95,8 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.58 2009/05/19 17:20:35 fabian #include "project.h" -#ifdef FEATURE_PTHREAD +/* For mutex semaphores only */ #include "jcc.h" -/* jcc.h is for mutex semaphores only */ -#endif /* def FEATURE_PTHREAD */ #include "jbsockets.h" #include "filters.h" @@ -947,7 +945,7 @@ void get_host_information(jb_socket afd, char **ip_address, char **hostname) { host = NULL; } -#elif FEATURE_PTHREAD +#elif def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&resolver_mutex); host = gethostbyaddr((const char *)&server.sin_addr, sizeof(server.sin_addr), AF_INET); @@ -1113,7 +1111,7 @@ unsigned long resolve_hostname_to_ip(const char *host) { hostp = NULL; } -#elif FEATURE_PTHREAD +#elif def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&resolver_mutex); while (NULL == (hostp = gethostbyname(host)) && (h_errno == TRY_AGAIN) && (dns_retries++ < MAX_DNS_RETRIES)) diff --git a/parsers.c b/parsers.c index 2e73ed96..c03a0902 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.163 2009/05/25 15:41:52 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.164 2009/05/25 15:42:40 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -2280,7 +2280,7 @@ static jb_err server_last_modified(struct client_state *csp, char **header) now = time(NULL); #ifdef HAVE_GMTIME_R gmtime_r(&now, &gmt); -#elif FEATURE_PTHREAD +#elif def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&gmtime_mutex); gmtime(&now); privoxy_mutex_unlock(&gmtime_mutex); @@ -2310,7 +2310,7 @@ static jb_err server_last_modified(struct client_state *csp, char **header) last_modified += rtime; #ifdef HAVE_GMTIME_R timeptr = gmtime_r(&last_modified, &gmt); -#elif FEATURE_PTHREAD +#elif def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&gmtime_mutex); timeptr = gmtime(&last_modified); privoxy_mutex_unlock(&gmtime_mutex); @@ -3030,7 +3030,7 @@ static jb_err client_if_modified_since(struct client_state *csp, char **header) tm += rtime * (negative ? -1 : 1); #ifdef HAVE_GMTIME_R timeptr = gmtime_r(&tm, &gmt); -#elif FEATURE_PTHREAD +#elif def MUTEX_LOCKS_AVAILABLE privoxy_mutex_lock(&gmtime_mutex); timeptr = gmtime(&tm); privoxy_mutex_unlock(&gmtime_mutex); -- 2.39.2