From ecfe14421862f2783003f3f8ae98b25fe2e34997 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 3 Mar 2025 13:31:10 +0100 Subject: [PATCH] Added a mutex lock to protect creating/deleting cStatus objects --- CONTRIBUTORS | 1 + HISTORY | 4 +++- status.c | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 6692078f..0c456e75 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2596,6 +2596,7 @@ Markus Ehrnsperger for implementing cStatus::OsdCurrentItem2() with the index of the current item for adding missing calls to cStatus::MsgOsdStatusMessage() and implementing cStatus::OsdStatusMessage2() with the type of the message + for suggesting to add a mutex lock to protect creating/deleting cStatus objects Werner Färber for reporting a bug in handling the cPluginManager::Active() result when pressing diff --git a/HISTORY b/HISTORY index 766fea0e..866b41c9 100644 --- a/HISTORY +++ b/HISTORY @@ -10090,7 +10090,7 @@ Video Disk Recorder Revision History - Added missing locks to SetMenuItem() functions. - Revised locking in cMenuSchedule and cMenuWhatsOn. -2025-03-02: +2025-03-03: - Added the "override" keyword to virtual functions reimplemented in derived classes. Plugins may want to do the same, but don't have to. @@ -10100,3 +10100,5 @@ Video Disk Recorder Revision History Plugins that use these recently introduced functions need to remove the '2' from the name. - The new virtual function cSkinDisplayMenu::SetItemEvent(..., const cTimer *Timer) can be used to get full access to the timer (if any) defined for this event. +- Added a mutex lock to protect creating/deleting cStatus objects (suggested by Markus + Ehrnsperger). diff --git a/status.c b/status.c index 2ca2f474..b6d5433b 100644 --- a/status.c +++ b/status.c @@ -4,23 +4,30 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: status.c 5.4 2025/03/02 21:02:12 kls Exp $ + * $Id: status.c 5.5 2025/03/03 13:31:10 kls Exp $ */ #include "status.h" +#include "thread.h" // --- cStatus --------------------------------------------------------------- cList cStatus::statusMonitors; +static cMutex Mutex; + cStatus::cStatus(void) { + Mutex.Lock(); statusMonitors.Add(this); + Mutex.Unlock(); } cStatus::~cStatus() { + Mutex.Lock(); statusMonitors.Del(this, false); + Mutex.Unlock(); } void cStatus::MsgChannelChange(const cChannel *Channel)