get_clf_timestamp(): Fix locking of localtime()
[privoxy.git] / errlog.c
index 8b12a43..7cc4e20 100644 (file)
--- a/errlog.c
+++ b/errlog.c
@@ -539,7 +539,6 @@ static inline size_t get_clf_timestamp(char *buffer, size_t buffer_size)
 #elif defined(MUTEX_LOCKS_AVAILABLE)
    privoxy_mutex_lock(&localtime_mutex);
    tm_now = localtime(&now);
-   privoxy_mutex_unlock(&localtime_mutex);
 #else
    tm_now = localtime(&now);
 #endif
@@ -548,6 +547,9 @@ static inline size_t get_clf_timestamp(char *buffer, size_t buffer_size)
    mins = hrs * 60 + tm_now->tm_min - gmt.tm_min;
 
    length = strftime(buffer, buffer_size, "%d/%b/%Y:%H:%M:%S ", tm_now);
+#if !defined(HAVE_LOCALTIME_R) && defined(MUTEX_LOCKS_AVAILABLE)
+   privoxy_mutex_unlock(&localtime_mutex);
+#endif
 
    if (length > (size_t)0)
    {