mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
timerd: prevent events from being deleted while sending them to neutrino
in neutrino's timer list sometimes appears an entry with random values after deleting one because thread safety is not guaranteed for timerd's event list while sending items to neutrino, so let's lock the mutex earlier and unlock it later Signed-off-by: Christian Schuett <Gaucho316@hotmail.com> Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
committed by
Jacek Jendrzej
parent
7f9dcb64b0
commit
a96fb7b7f0
@@ -277,12 +277,24 @@ bool CTimerManager::stopEvent(int peventID)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
int CTimerManager::lockEvents()
|
||||
{
|
||||
return pthread_mutex_lock(&tm_eventsMutex);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
int CTimerManager::unlockEvents()
|
||||
{
|
||||
return pthread_mutex_unlock(&tm_eventsMutex);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
bool CTimerManager::listEvents(CTimerEventMap &Events)
|
||||
{
|
||||
if(!&Events)
|
||||
return false;
|
||||
|
||||
pthread_mutex_lock(&tm_eventsMutex);
|
||||
|
||||
Events.clear();
|
||||
for (CTimerEventMap::iterator pos = events.begin(); pos != events.end(); ++pos)
|
||||
@@ -290,7 +302,6 @@ bool CTimerManager::listEvents(CTimerEventMap &Events)
|
||||
pos->second->Refresh();
|
||||
Events[pos->second->eventID] = pos->second;
|
||||
}
|
||||
pthread_mutex_unlock(&tm_eventsMutex);
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user