Ticket #11331: mythbackend_slave_shutdown_busy.patch

File mythbackend_slave_shutdown_busy.patch, 4.4 KB (added by Jan.Lentfer@…, 10 years ago)

patch against head

  • mythtv/programs/mythbackend/encoderlink.cpp

    diff --git a/mythtv/programs/mythbackend/encoderlink.cpp b/mythtv/programs/mythbackend/encoderlink.cpp
    index c00ba77..788f3fc 100644
    a b int EncoderLink::SetSignalMonitoringRate(int rate, int notifyFrontend) 
    347347
    348348/** \brief Tell a slave to go to sleep
    349349 */
    350 bool EncoderLink::GoToSleep(void)
     350int EncoderLink::GoToSleep(void)
    351351{
    352352    if (IsLocal() || !sock)
    353353        return false;
  • mythtv/programs/mythbackend/encoderlink.h

    diff --git a/mythtv/programs/mythbackend/encoderlink.h b/mythtv/programs/mythbackend/encoderlink.h
    index 8de94d9..422854d 100644
    a b class EncoderLink 
    6464    TVRec *GetTVRec(void) { return tv; }
    6565
    6666    /// \brief Tell a slave backend to go to sleep
    67     bool GoToSleep(void);
     67    int GoToSleep(void);
    6868    int LockTuner(void);
    6969    /// \brief Unlock the tuner.
    7070    /// \sa LockTuner(), IsTunerLocked()
  • mythtv/programs/mythbackend/mainserver.cpp

    diff --git a/mythtv/programs/mythbackend/mainserver.cpp b/mythtv/programs/mythbackend/mainserver.cpp
    index 8996d48..1895619 100644
    a b void MainServer::HandleGoToSleep(PlaybackSock *pbs) 
    27802780    QString sleepCmd = gCoreContext->GetSetting("SleepCommand");
    27812781    if (!sleepCmd.isEmpty())
    27822782    {
    2783         strlist << "OK";
     2783        int retval;
     2784        retval = myth_system(sleepCmd);
     2785        if (retval == 2)
     2786                strlist << "BUSY";
     2787        else if (retval != GENERIC_EXIT_OK)
     2788                strlist << "ERROR: SleepCommand exited with error";
     2789        else
     2790                strlist << "OK";
    27842791        SendResponse(pbs->getSocket(), strlist);
    27852792        LOG(VB_GENERAL, LOG_NOTICE,
    27862793            "Received GO_TO_SLEEP command from master, running SleepCommand.");
    2787         myth_system(sleepCmd);
    27882794    }
    27892795    else
    27902796    {
  • mythtv/programs/mythbackend/playbacksock.cpp

    diff --git a/mythtv/programs/mythbackend/playbacksock.cpp b/mythtv/programs/mythbackend/playbacksock.cpp
    index 65a49ac..7dbcea6 100644
    a b bool PlaybackSock::SendReceiveStringList( 
    107107
    108108/** \brief Tells a slave to go to sleep
    109109 */
    110 bool PlaybackSock::GoToSleep(void)
     110int PlaybackSock::GoToSleep(void)
    111111{
    112     QStringList strlist(QString("GO_TO_SLEEP"));
     112    QStringList strlist( QString("GO_TO_SLEEP") );
    113113
    114     return SendReceiveStringList(strlist, 1) && (strlist[0] == "OK");
     114    if (SendReceiveStringList(strlist, 1))
     115    {
     116      if (strlist[0] == "OK")
     117        return 1;
     118      else if (strlist[0] == "BUSY")
     119        return -1;
     120    }
     121
     122    return 0;
    115123}
    116124
    117125/**
  • mythtv/programs/mythbackend/playbacksock.h

    diff --git a/mythtv/programs/mythbackend/playbacksock.h b/mythtv/programs/mythbackend/playbacksock.h
    index c273604..c61cde4 100644
    a b class PlaybackSock : public ReferenceCounter 
    5959    void setIP(QString &lip) { ip = lip; }
    6060    QString getIP(void) const { return ip; }
    6161
    62     bool GoToSleep(void);
     62    int GoToSleep(void);
    6363    void GetDiskSpace(QStringList &o_strlist);
    6464    int DeleteFile(const QString &filename, const QString &sgroup);
    6565    int StopRecording(const ProgramInfo *pginfo);
  • mythtv/programs/mythbackend/scheduler.cpp

    diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp
    index 0f0e917..354f331 100644
    a b void Scheduler::PutInactiveSlavesToSleep(void) 
    29532953{
    29542954    int prerollseconds = 0;
    29552955    int secsleft = 0;
     2956    int retval = 0;
    29562957    EncoderLink *enc = NULL;
    29572958
    29582959    bool someSlavesCanSleep = false;
    void Scheduler::PutInactiveSlavesToSleep(void) 
    30623063                    QString("    Commanding %1 to go to sleep.")
    30633064                        .arg(thisHost));
    30643065
    3065                 if (enc->GoToSleep())
     3066                retval = enc->GoToSleep();
     3067
     3068                if (retval == -1)
     3069                {
     3070                    VERBOSE(VB_IMPORTANT, LOC_WARN + QString("Unable to "
     3071                            "shutdown %1 slave backend, reported "
     3072                            "back BUSY. Doing nothing.").arg(thisHost));
     3073                    break;
     3074                }
     3075                else if (retval == 1)
    30663076                {
    30673077                    QMap<int, EncoderLink *>::Iterator slviter =
    30683078                        m_tvList->begin();