add_cookie_expiry_date(): Use privoxy_gmtime_r()
authorFabian Keil <fk@fabiankeil.de>
Sun, 7 Jun 2020 15:50:23 +0000 (17:50 +0200)
committerFabian Keil <fk@fabiankeil.de>
Mon, 8 Jun 2020 13:34:36 +0000 (15:34 +0200)
parsers.c

index 11d28c7..40c58f3 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -4040,29 +4040,15 @@ static void add_cookie_expiry_date(char **cookie, time_t lifetime)
    char tmp[50];
    struct tm *timeptr = NULL;
    time_t expiry_date = time(NULL) + lifetime;
    char tmp[50];
    struct tm *timeptr = NULL;
    time_t expiry_date = time(NULL) + lifetime;
-#ifdef HAVE_GMTIME_R
    struct tm gmt;
 
    struct tm gmt;
 
-   timeptr = gmtime_r(&expiry_date, &gmt);
-#elif defined(MUTEX_LOCKS_AVAILABLE)
-   privoxy_mutex_lock(&gmtime_mutex);
-   timeptr = gmtime(&expiry_date);
-#else
-   timeptr = gmtime(&expiry_date);
-#endif
-
+   timeptr = privoxy_gmtime_r(&expiry_date, &gmt);
    if (NULL == timeptr)
    {
    if (NULL == timeptr)
    {
-#if !defined(HAVE_GMTIME_R) && defined(MUTEX_LOCKS_AVAILABLE)
-      privoxy_mutex_unlock(&gmtime_mutex);
-#endif
       log_error(LOG_LEVEL_FATAL,
          "Failed to get the time in add_cooky_expiry_date()");
    }
    strftime(tmp, sizeof(tmp), "; expires=%a, %d-%b-%Y %H:%M:%S GMT", timeptr);
       log_error(LOG_LEVEL_FATAL,
          "Failed to get the time in add_cooky_expiry_date()");
    }
    strftime(tmp, sizeof(tmp), "; expires=%a, %d-%b-%Y %H:%M:%S GMT", timeptr);
-#if !defined(HAVE_GMTIME_R) && defined(MUTEX_LOCKS_AVAILABLE)
-   privoxy_mutex_unlock(&gmtime_mutex);
-#endif
    if (JB_ERR_OK != string_append(cookie, tmp))
    {
       log_error(LOG_LEVEL_FATAL, "Out of memory in add_cooky_expiry()");
    if (JB_ERR_OK != string_append(cookie, tmp))
    {
       log_error(LOG_LEVEL_FATAL, "Out of memory in add_cooky_expiry()");