Ticket #6595: 6595-v1.patch

File 6595-v1.patch, 3.6 KB (added by danielk, 10 years ago)

possible fix

  • programs/mythbackend/mainserver.h

     
    193193    vector<PlaybackSock *> playbackList;
    194194    vector<FileTransfer *> fileTransferList;
    195195
    196     QTimer *masterServerReconnect;
     196    QTimer *masterServerReconnect; // audited ref #5318
    197197    PlaybackSock *masterServer;
    198198   
    199199    bool ismaster;
     
    225225    static QMutex truncate_and_close_lock;
    226226
    227227    int m_exitCode;
     228
     229    static const uint kMasterServerReconnectTimeout;
    228230};
    229231
    230232#endif
  • programs/mythbackend/mainserver.cpp

     
    109109};
    110110
    111111QMutex MainServer::truncate_and_close_lock;
     112const uint MainServer::kMasterServerReconnectTimeout = 1000; //ms
    112113
    113114class ProcessRequestThread : public QThread
    114115{
     
    207208        masterServerReconnect->setSingleShot(true);
    208209        connect(masterServerReconnect, SIGNAL(timeout()), this,
    209210                SLOT(reconnectTimeout()));
    210         masterServerReconnect->start(1000);
     211        masterServerReconnect->start(kMasterServerReconnectTimeout);
    211212    }
    212213
    213214    deferredDeleteTimer = new QTimer(this);
     
    844845        if (me->Message().left(6) == "LOCAL_")
    845846            return;
    846847
     848        if (me->Message() == "RECONNECT_TO_MASTER")
     849        {
     850            VERBOSE(VB_IMPORTANT, "Got RECONNECT_TO_MASTER message");
     851            masterServerReconnect->start(kMasterServerReconnectTimeout);
     852        }
     853
    847854        broadcast = QStringList( "BACKEND_MESSAGE" );
    848855        broadcast << me->Message();
    849856        broadcast += me->ExtraDataList();
     
    45964603            sockListLock.unlock();
    45974604            masterServer->DownRef();
    45984605            masterServer = NULL;
    4599             masterServerReconnect->start(1000);
     4606            VERBOSE(VB_IMPORTANT, "Sending RECONNECT_TO_MASTER message");
     4607            MythEvent me("RECONNECT_TO_MASTER");
     4608            gContext->dispatch(me);
    46004609            return;
    46014610        }
    46024611        else if (sock == socket)
     
    49664975    if (!masterServerSock->connect(server, port))
    49674976    {
    49684977        VERBOSE(VB_IMPORTANT, "Connection to master server timed out.");
    4969         masterServerReconnect->start(1000);
     4978        masterServerReconnect->start(kMasterServerReconnectTimeout);
    49704979        masterServerSock->DownRef();
    49714980        return;
    49724981    }
     
    49744983    if (masterServerSock->state() != MythSocket::Connected)
    49754984    {
    49764985        VERBOSE(VB_IMPORTANT, "Could not connect to master server.");
    4977         masterServerReconnect->start(1000);
     4986        masterServerReconnect->start(kMasterServerReconnectTimeout);
    49784987        masterServerSock->DownRef();
    49794988        return;
    49804989    }
     
    50075016        }
    50085017    }
    50095018
    5010     masterServerSock->writeStringList(strlist);
    5011     masterServerSock->readStringList(strlist);
    5012     if (strlist.empty() || strlist[0] == "ERROR")
     5019    if (!masterServerSock->writeStringList(strlist) ||
     5020        !masterServerSock->readStringList(strlist) ||
     5021        strlist.empty() || strlist[0] == "ERROR")
    50135022    {
    50145023        masterServerSock->DownRef();
    50155024        masterServerSock->Unlock();
     
    50275036                     QString(", error was %1").arg(strlist[1]) :
    50285037                     QString(", remote error")));
    50295038        }
    5030         masterServerReconnect->start(1000);
     5039        masterServerReconnect->start(kMasterServerReconnectTimeout);
    50315040        return;
    50325041    }
    50335042