From: Fabian Keil <fk@fabiankeil.de>
Date: Sun, 7 Jun 2020 15:52:38 +0000 (+0200)
Subject: client_if_modified_since(): Use privoxy_gmtime_r()
X-Git-Tag: v_3_0_29~290
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/@default-cgi@edit-actions-add-url-form?a=commitdiff_plain;h=988422b1a6d68cb306bc50ff1860be82d47445ba;p=privoxy.git

client_if_modified_since(): Use privoxy_gmtime_r()
---

diff --git a/parsers.c b/parsers.c
index 1e71b61d..6b93b747 100644
--- a/parsers.c
+++ b/parsers.c
@@ -3403,9 +3403,7 @@ static jb_err client_host(struct client_state *csp, char **header)
 static jb_err client_if_modified_since(struct client_state *csp, char **header)
 {
    char newheader[50];
-#ifdef HAVE_GMTIME_R
    struct tm gmt;
-#endif
    struct tm *timeptr = NULL;
    time_t tm = 0;
    const char *newval;
@@ -3463,29 +3461,16 @@ static jb_err client_if_modified_since(struct client_state *csp, char **header)
                   *header);
             }
             tm += rtime * (negative_range ? -1 : 1);
-#ifdef HAVE_GMTIME_R
-            timeptr = gmtime_r(&tm, &gmt);
-#elif defined(MUTEX_LOCKS_AVAILABLE)
-            privoxy_mutex_lock(&gmtime_mutex);
-            timeptr = gmtime(&tm);
-#else
-            timeptr = gmtime(&tm);
-#endif
+            timeptr = privoxy_gmtime_r(&tm, &gmt);
             if ((NULL == timeptr) || !strftime(newheader,
                   sizeof(newheader), "%a, %d %b %Y %H:%M:%S GMT", timeptr))
             {
-#if !defined(HAVE_GMTIME_R) && defined(MUTEX_LOCKS_AVAILABLE)
-               privoxy_mutex_unlock(&gmtime_mutex);
-#endif
                log_error(LOG_LEVEL_ERROR,
                   "Randomizing '%s' failed. Crunching the header without replacement.",
                   *header);
                freez(*header);
                return JB_ERR_OK;
             }
-#if !defined(HAVE_GMTIME_R) && defined(MUTEX_LOCKS_AVAILABLE)
-            privoxy_mutex_unlock(&gmtime_mutex);
-#endif
             freez(*header);
             *header = strdup("If-Modified-Since: ");
             string_append(header, newheader);