Skip to content

Commit 830cfe2

Browse files
committed
Revert d028e48, split hostname lock into two mutexes.
This puts m_localHostname and m_masterHostname under separate locks, preventing issues when GetMasterHostName initially populates the latter value.
1 parent d028e48 commit 830cfe2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mythtv/libs/libmythbase/mythcorecontext.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ class MythCoreContextPrivate : public QObject
5656
QObject *m_GUIobject;
5757
QString m_appBinaryVersion;
5858

59-
QMutex m_hostnameLock; ///< Locking for thread-safe copying of:
59+
QMutex m_localHostLock; ///< Locking for thread-safe copying of:
6060
QString m_localHostname; ///< hostname from mysql.txt or gethostname()
61+
QMutex m_masterHostLock;
6162
QString m_masterHostname; ///< master backend hostname
6263

6364
QMutex m_sockLock; ///< protects both m_serverSock and m_eventSock
@@ -842,7 +843,7 @@ QString MythCoreContext::GetMasterHostPrefix(QString storageGroup)
842843

843844
QString MythCoreContext::GetMasterHostName(void)
844845
{
845-
QMutexLocker locker(&d->m_hostnameLock);
846+
QMutexLocker locker(&d->m_masterHostLock);
846847

847848
if (d->m_masterHostname.isEmpty())
848849
{
@@ -876,7 +877,7 @@ void MythCoreContext::ActivateSettingsCache(bool activate)
876877

877878
QString MythCoreContext::GetHostName(void)
878879
{
879-
// QMutexLocker (&d->m_hostnameLock);
880+
QMutexLocker (&d->m_localHostLock);
880881
QString tmp = d->m_localHostname;
881882
tmp.detach();
882883
return tmp;
@@ -1324,7 +1325,7 @@ void MythCoreContext::dispatchNow(const MythEvent &event)
13241325

13251326
void MythCoreContext::SetLocalHostname(const QString &hostname)
13261327
{
1327-
// QMutexLocker locker(&d->m_hostnameLock);
1328+
QMutexLocker locker(&d->m_localHostLock);
13281329
d->m_localHostname = hostname;
13291330
d->m_database->SetLocalHostname(hostname);
13301331
}

0 commit comments

Comments
 (0)