Ticket #2493: timeout.patch

File timeout.patch, 5.9 KB (added by Tony Lill <ajlill@…>, 13 years ago)

Patch to speed up QUERY_RECORDINGS and avoid MythSocket? timeout

  • libs/libmythtv/remoteutil.h

     
    1919    long long usedSpaceKB;
    2020};
    2121
    22 vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype);
     22vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype, QString where);
    2323vector<FileSystemInfo> RemoteGetFreeSpace();
    2424bool RemoteGetLoad(float load[3]);
    2525bool RemoteGetUptime(time_t &uptime);
  • libs/libmythtv/tv_play.cpp

     
    61446144    // Build jumpMenu of recorded program titles
    61456145    ProgramInfo *p;
    61466146    progLists.clear();
     6147    QString whereClause = " and recorded.recgroup = \"" + playbackinfo->recgroup + "\"";
    61476148    vector<ProgramInfo *> *infoList;
    6148     infoList = RemoteGetRecordedList(false);
     6149    infoList = RemoteGetRecordedList(false, whereClause);
    61496150
    61506151    bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
    61516152
  • libs/libmythtv/remoteutil.cpp

     
    66#include "mythcontext.h"
    77#include "remoteencoder.h"
    88
    9 vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype)
     9vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype, QString whereClause)
    1010{
    1111    QString str = "QUERY_RECORDINGS ";
    1212    if (deltype)
    1313        str += "Delete";
    1414    else
    1515        str += "Play";
     16    str += whereClause;
    1617
    1718    QStringList strlist = str;
    1819
  • programs/mythfrontend/playbackbox.cpp

     
    14791479
    14801480    bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
    14811481
     1482    QString whereClause = "";
     1483    if( recGroup != "All Programs" ) {
     1484      if(recGroupType[recGroup] == "category")
     1485        whereClause = " and recorded.category = \"" + recGroup + "\"";
     1486      else
     1487        whereClause = " and recorded.recgroup = \"" + recGroup + "\"";
     1488    }   
    14821489    vector<ProgramInfo *> *infoList;
    1483     infoList = RemoteGetRecordedList(listOrder == 0 || type == Delete);
     1490    infoList = RemoteGetRecordedList(listOrder == 0 || type == Delete, whereClause);
    14841491    if (infoList)
    14851492    {
    14861493        sortedList[""] = "";
  • programs/mythbackend/mainserver.h

     
    7272    void HandleDone(MythSocket *socket);
    7373
    7474    void HandleIsActiveBackendQuery(QStringList &slist, PlaybackSock *pbs);
    75     void HandleQueryRecordings(QString type, PlaybackSock *pbs);
     75    void HandleQueryRecordings(QStringList &tokens, PlaybackSock *pbs);
    7676    void HandleStopRecording(QStringList &slist, PlaybackSock *pbs);
    7777    void DoHandleStopRecording(ProgramInfo *pginfo, PlaybackSock *pbs);
    7878    void HandleDeleteRecording(QStringList &slist, PlaybackSock *pbs,
  • programs/mythbackend/mainserver.cpp

     
    351351
    352352    if (command == "QUERY_RECORDINGS")
    353353    {
    354         if (tokens.size() != 2)
     354        if (tokens.size() < 2)
    355355            VERBOSE(VB_IMPORTANT, "Bad QUERY_RECORDINGS query");
    356356        else
    357             HandleQueryRecordings(tokens[1], pbs);
     357            HandleQueryRecordings(tokens, pbs);
    358358    }
    359359    else if (command == "QUERY_FREE_SPACE")
    360360    {
     
    10031003    }
    10041004}
    10051005
    1006 void MainServer::HandleQueryRecordings(QString type, PlaybackSock *pbs)
     1006void MainServer::HandleQueryRecordings(QStringList &tokens, PlaybackSock *pbs)
    10071007{
     1008  QString type = tokens[1];
    10081009    MythSocket *pbssock = pbs->getSocket();
    10091010    bool islocal = pbs->isLocal();
    10101011    QString playbackhost = pbs->getHostname();
     1012    int i;
    10111013
    10121014    QString fs_db_name = "";
    10131015
     
    10741076        "  recorded.progstart = recordedprogram.starttime ) "
    10751077        "WHERE ( recorded.deletepending = 0 OR "
    10761078        "        DATE_ADD(recorded.lastmodified, INTERVAL 5 MINUTE) <= NOW() "
    1077         "      ) "
    1078         "ORDER BY recorded.starttime";
     1079      "      )";
     1080    for( i = 2; i < tokens.size(); i++ ) {
     1081      thequery += " "+tokens[i];
     1082    }
     1083        thequery += " ORDER BY recorded.starttime";
    10791084
    10801085    if (type == "Delete")
    10811086        thequery += " DESC";
     
    12151220
    12161221            QString lpath = fileprefix + "/" + basename;
    12171222            PlaybackSock *slave = NULL;
    1218             QFile checkFile(lpath);
     1223            //QFile checkFile(lpath);
    12191224
    12201225            if (proginfo->hostname != gContext->GetHostName())
    1221                 slave = getSlaveByHostname(proginfo->hostname);
     1226                slave = getSlaveByHostname(proginfo->hostname); 
    12221227
    1223             if ((masterBackendOverride && checkFile.exists()) ||
     1228            /* In the original if statement,
     1229
     1230            if ((masterBackendOverride && checkFile.exists()) ||
    12241231                (proginfo->hostname == gContext->GetHostName()) ||
    12251232                (!slave && checkFile.exists()))
     1233
     1234               we want to eliminate the costly checkFile
     1235               call. Presumably this is used in the case where master
     1236               and slave use the same shared directory. If we assume
     1237               that is false, then that check can be replaced by
     1238               hostname compare, which reduces the logic to
     1239
     1240               if( ( A && B ) || B || ( C && B ) )
     1241
     1242               which reduces nicely to  if(B) */
     1243            if (proginfo->hostname == gContext->GetHostName())
    12261244            {
    12271245                if (islocal)
    12281246                    proginfo->pathname = lpath;