From e6234a06267fd5df49e04bb1afc5e52ed546d420 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Tue, 3 Jan 2017 15:56:58 +0100 Subject: [PATCH] src/timerd/timermanager.cpp dont unlock on other errors Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/950963146a9b8589837a3f32e6ba37757be42415 Author: Jacek Jendrzej Date: 2017-01-03 (Tue, 03 Jan 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/timerd/timermanager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/timerd/timermanager.cpp b/src/timerd/timermanager.cpp index e18e1612f..fec447b79 100644 --- a/src/timerd/timermanager.cpp +++ b/src/timerd/timermanager.cpp @@ -723,7 +723,6 @@ bool CTimerManager::shutdown() time_t nextAnnounceTime=0; bool status=false; timer_is_rec = false; - dprintf("stopping timermanager thread ...\n"); dprintf("Waiting for timermanager thread to terminate ...\n"); @@ -737,7 +736,8 @@ bool CTimerManager::shutdown() saveEventsToConfig(); dprintf("shutdown: saved config\n"); } - if (pthread_mutex_trylock(&tm_eventsMutex) == EBUSY) + int rc = pthread_mutex_trylock(&tm_eventsMutex); + if (rc == EBUSY) { dprintf("error: mutex is still LOCKED\n"); return false; @@ -771,8 +771,8 @@ bool CTimerManager::shutdown() timer_minutes = (nextAnnounceTime - 3*60)/60; } dprintf("shutdown: timeset: %d timer_minutes %ld\n", timeset, timer_minutes); - - pthread_mutex_unlock(&tm_eventsMutex); + if(rc == 0) + pthread_mutex_unlock(&tm_eventsMutex); return status; } //------------------------------------------------------------