Ticket #9016: 0001-Redo-the-verbose_lock-in-myth_system.patch

File 0001-Redo-the-verbose_lock-in-myth_system.patch, 1.5 KB (added by beirdo, 9 years ago)
  • mythtv/libs/libmythdb/mythsystem.cpp

    From 9a6535fba1ccef84fd8ede246912e0d7a7bf3eef Mon Sep 17 00:00:00 2001
    From: Gavin Hurlbut <gjhurlbu@gmail.com>
    Date: Thu, 7 Oct 2010 01:17:27 -0700
    Subject: [PATCH] Redo the verbose_lock in myth_system
    
    
    diff --git a/mythtv/libs/libmythdb/mythsystem.cpp b/mythtv/libs/libmythdb/mythsystem.cpp
    index 7a4bcdb..b6196dd 100644
    a b pid_t myth_system_fork(const QString &command, uint &result) 
    373373{
    374374    QString LOC_ERR = QString("myth_system('%1'): Error: ").arg(command);
    375375    VERBOSE(VB_GENERAL, QString("Launching: %1") .arg(command));
     376
     377    // Due to the possibility of forking during a call to currentDateTime from within
     378    // VERBOSE, and thereby breaking VERBOSE in the children, lock the verbose_mutex
     379    // to prevent this from ever happening.
     380    verbose_mutex.lock();
     381
    376382    pid_t child = fork();
    377383
     384    verbose_mutex.unlock();
     385
    378386    if (child < 0)
    379387    {
    380388        /* Fork failed */
    pid_t myth_system_fork(const QString &command, uint &result) 
    386394    else if (child == 0)
    387395    {
    388396        /* Child */
    389         /* In case we forked WHILE it was locked */
    390         bool unlocked = verbose_mutex.tryLock();
    391         verbose_mutex.unlock();
    392         if( !unlocked )
    393             VERBOSE(VB_GENERAL, "Cleared parent's verbose lock");
    394 
    395397        /* Close all open file descriptors except stdout/stderr */
    396398        for (int i = sysconf(_SC_OPEN_MAX) - 1; i > 2; i--)
    397399            close(i);