Ticket #9421: 0002-Move-timeout-setting-to-before-fork.patch

File 0002-Move-timeout-setting-to-before-fork.patch, 3.0 KB (added by beirdo, 13 years ago)
  • mythtv/libs/libmythdb/system-unix.cpp

    From 792b39f941abcad4c39269abcb03c8ba364cab50 Mon Sep 17 00:00:00 2001
    From: Gavin Hurlbut <ghurlbut@mythtv.org>
    Date: Sun, 9 Jan 2011 14:49:47 -0800
    Subject: [PATCH 2/2] Move timeout setting to before fork
    
    ---
     mythtv/libs/libmythdb/system-unix.cpp    |   12 ++++++------
     mythtv/libs/libmythdb/system-windows.cpp |   11 +++++------
     2 files changed, 11 insertions(+), 12 deletions(-)
    
    diff --git a/mythtv/libs/libmythdb/system-unix.cpp b/mythtv/libs/libmythdb/system-unix.cpp
    index 0f29c6e..f96339d 100644
    a b void MythSystemUnix::Fork(time_t timeout) 
    626626    if (GetSetting("SetDirectory") && !dir.isEmpty())
    627627        directory = strdup(dir.toUtf8().constData());
    628628
     629    /* Do this before forking in case the child miserably fails */
     630    m_timeout = timeout;
     631    if( timeout )
     632        m_timeout += time(NULL);
     633
    629634    pid_t child = fork();
    630635
    631636    if (child < 0)
    void MythSystemUnix::Fork(time_t timeout) 
    642647        m_pid = child;
    643648        SetStatus( GENERIC_EXIT_RUNNING );
    644649
    645         m_timeout = timeout;
    646 
    647650        VERBOSE(VB_SYSTEM|VB_EXTRA,
    648651                    QString("Managed child (PID: %1) has started! "
    649652                            "%2%3 command=%4, timeout=%5")
    650653                        .arg(m_pid) .arg(GetSetting("UseShell") ? "*" : "")
    651654                        .arg(GetSetting("RunInBackground") ? "&" : "")
    652                         .arg(GetLogCmd()) .arg(m_timeout));
    653 
    654         if( timeout )
    655             m_timeout += time(NULL);
     655                        .arg(GetLogCmd()) .arg(timeout));
    656656
    657657        /* close unused pipe ends */
    658658        CLOSE(p_stdin[0]);
  • mythtv/libs/libmythdb/system-windows.cpp

    diff --git a/mythtv/libs/libmythdb/system-windows.cpp b/mythtv/libs/libmythdb/system-windows.cpp
    index 2e390c5..df92dfd 100644
    a b void MythSystemWindows::Fork(time_t timeout) 
    633633    PROCESS_INFORMATION pi;
    634634    ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
    635635
     636    m_timeout = timeout;
     637    if( timeout )
     638        m_timeout += time(NULL);
     639
    636640    bool success = CreateProcess(NULL,
    637641                    command,       // command line
    638642                    NULL,          // process security attributes
    void MythSystemWindows::Fork(time_t timeout) 
    655659        m_child = pi.hProcess;
    656660        SetStatus( GENERIC_EXIT_RUNNING );
    657661
    658         m_timeout = timeout;
    659 
    660662        VERBOSE(VB_SYSTEM|VB_EXTRA,
    661663                QString("Managed child (Handle: %1) has started! "
    662664                        "%2%3 command=%4, timeout=%5")
    663665                    .arg((long long)m_child)
    664666                    .arg(GetSetting("UseShell") ? "*" : "")
    665667                    .arg(GetSetting("RunInBackground") ? "&" : "")
    666                     .arg(GetLogCmd()) .arg(m_timeout));
    667 
    668         if( timeout )
    669             m_timeout += time(NULL);
     668                    .arg(GetLogCmd()) .arg(timeout));
    670669
    671670        /* close unused pipe ends */
    672671        CLOSE(p_stdin[0]);