From f98a7f1579136d31f46f1481ea96b4a1141103e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20H=C3=B6hna?= Date: Fri, 23 Oct 2015 09:35:24 +0200 Subject: [PATCH] rrd_parsetime now unlocks its mutex also after parsing errors. --- src/rrd_parsetime.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/rrd_parsetime.c b/src/rrd_parsetime.c index 9e2bd7f7..b9f2c212 100644 --- a/src/rrd_parsetime.c +++ b/src/rrd_parsetime.c @@ -832,16 +832,28 @@ static char *day( static mutex_t parsetime_mutex = MUTEX_INITIALIZER; +static char *rrd_parsetime_nomt( + const char *tspec, + rrd_time_value_t * ptv); + char *rrd_parsetime( const char *tspec, rrd_time_value_t * ptv) { - time_t now = time(NULL); - int hr = 0; - /* yes this code is non re-entrant ... so lets make sure we do not run in twice */ mutex_lock(&parsetime_mutex); + char *result = rrd_parsetime_nomt(tspec, ptv); + mutex_unlock(&parsetime_mutex); + return result; +} + +static char *rrd_parsetime_nomt( + const char *tspec, + rrd_time_value_t * ptv) +{ + time_t now = time(NULL); + int hr = 0; /* this MUST be initialized to zero for midnight/noon/teatime */ -- 2.47.2