From: Jean-Michel Vourgère Date: Sat, 8 Aug 2015 13:05:30 +0000 (+0200) Subject: journal_init: release mutex on failure X-Git-Tag: v1.5.4~1^2~2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=7ed9c753f1a46edd650503f9fde879201973b8dd;p=thirdparty%2Frrdtool-1.x.git journal_init: release mutex on failure --- diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index f49ce58d..b15baa02 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -3031,16 +3031,18 @@ static void journal_init(void) /* {{{ */ DIR *dir; struct dirent *dent; char path[PATH_MAX+1]; + int locked_done = 0; if (journal_dir == NULL) return; pthread_mutex_lock(&journal_lock); + locked_done = 1; journal_cur = calloc(1, sizeof(journal_set)); if (journal_cur == NULL) { RRDD_LOG(LOG_CRIT, "journal_rotate: malloc(journal_set) failed\n"); - return; + goto done; } RRDD_LOG(LOG_INFO, "checking for journal files"); @@ -3062,7 +3064,7 @@ static void journal_init(void) /* {{{ */ dir = opendir(journal_dir); if (!dir) { RRDD_LOG(LOG_CRIT, "journal_init: opendir(%s) failed\n", journal_dir); - return; + goto done; } while ((dent = readdir(dir)) != NULL) { @@ -3093,10 +3095,11 @@ static void journal_init(void) /* {{{ */ if (had_journal && config_flush_at_shutdown) flush_old_values(-1); - pthread_mutex_unlock(&journal_lock); - RRDD_LOG(LOG_INFO, "journal processing complete"); +done: + if (locked_done) + pthread_mutex_unlock(&journal_lock); } /* }}} static void journal_init */ static void free_listen_socket(listen_socket_t *sock) /* {{{ */