Ticket #11066: 0001-avoid-deadlock-in-MythSystem.patch

File 0001-avoid-deadlock-in-MythSystem.patch, 3.0 KB (added by Jack Thomasson <jkt@…>, 7 years ago)

git patch

  • mythtv/libs/libmythbase/system-unix.cpp

    From 54a63ae8e408d36c057aba7fb509c6ba652b0f77 Mon Sep 17 00:00:00 2001
    From: Jack Thomasson <jkt@moonlitsw.com>
    Date: Mon, 3 Sep 2012 09:21:54 -0600
    Subject: [PATCH] avoid deadlock in MythSystem
    
    in MythSystemManager::append do not hold fdLock while calling
    MythSystemIOHandler::insert which locks m_pLock
    
    avoids deadlock in MythSystemIOHandler::run which holds m_pLock while calling
    MythSystemIOHandler::HandleRead which locks fdLock
    ---
     mythtv/libs/libmythbase/system-unix.cpp    |    6 ++++--
     mythtv/libs/libmythbase/system-windows.cpp |    6 ++++--
     2 files changed, 8 insertions(+), 4 deletions(-)
    
    diff --git a/mythtv/libs/libmythbase/system-unix.cpp b/mythtv/libs/libmythbase/system-unix.cpp
    index a7a24c9..c11be24 100644
    a b void MythSystemManager::append(MythSystemUnix *ms) 
    441441    m_pMap.insert(ms->m_pid, ms);
    442442    m_mapLock.unlock();
    443443
    444     fdLock.lock();
    445444    if( ms->GetSetting("UseStdin") )
    446445        writeThread->insert(ms->m_stdpipe[0], ms->GetBuffer(0));
    447446
    void MythSystemManager::append(MythSystemUnix *ms) 
    450449        FDType_t *fdType = new FDType_t;
    451450        fdType->ms = ms;
    452451        fdType->type = 1;
     452        fdLock.lock();
    453453        fdMap.insert( ms->m_stdpipe[1], fdType );
     454        fdLock.unlock();
    454455        readThread->insert(ms->m_stdpipe[1], ms->GetBuffer(1));
    455456    }
    456457
    void MythSystemManager::append(MythSystemUnix *ms) 
    459460        FDType_t *fdType = new FDType_t;
    460461        fdType->ms = ms;
    461462        fdType->type = 2;
     463        fdLock.lock();
    462464        fdMap.insert( ms->m_stdpipe[2], fdType );
    463465        readThread->insert(ms->m_stdpipe[2], ms->GetBuffer(2));
     466        fdLock.unlock();
    464467    }
    465     fdLock.unlock();
    466468}
    467469
    468470void MythSystemManager::jumpAbort(void)
  • mythtv/libs/libmythbase/system-windows.cpp

    diff --git a/mythtv/libs/libmythbase/system-windows.cpp b/mythtv/libs/libmythbase/system-windows.cpp
    index 71832ff..063f3b4 100644
    a b void MythSystemManager::append(MythSystemWindows *ms) 
    399399    ChildListRebuild();
    400400    m_mapLock.unlock();
    401401
    402     fdLock.lock();
    403402    if( ms->GetSetting("UseStdin") )
    404403        writeThread->insert(ms->m_stdpipe[0], ms->GetBuffer(0));
    405404
    void MythSystemManager::append(MythSystemWindows *ms) 
    408407        FDType_t *fdType = new FDType_t;
    409408        fdType->ms = ms;
    410409        fdType->type = 1;
     410        fdLock.lock();
    411411        fdMap.insert( ms->m_stdpipe[1], fdType );
     412        fdLock.unlock();
    412413        readThread->insert(ms->m_stdpipe[1], ms->GetBuffer(1));
    413414    }
    414415
    void MythSystemManager::append(MythSystemWindows *ms) 
    417418        FDType_t *fdType = new FDType_t;
    418419        fdType->ms = ms;
    419420        fdType->type = 2;
     421        fdLock.lock();
    420422        fdMap.insert( ms->m_stdpipe[2], fdType );
     423        fdLock.unlock();
    421424        readThread->insert(ms->m_stdpipe[2], ms->GetBuffer(2));
    422425    }
    423     fdLock.unlock();
    424426}
    425427
    426428void MythSystemManager::jumpAbort(void)