Ticket #3279: backend-reconnect-180707.diff

File backend-reconnect-180707.diff, 2.9 KB (added by devel@…, 18 years ago)

updated patch for server reconnect

  • mythtv/libs/libmyth/mythcontext.cpp

     
    875893                                       bool blockingClient)
    876894{
    877895    MythSocket *serverSock = NULL;
     896    MythBusyDialog *busy = NULL;
    878897    int cnt = 1;
     898   
     899    bool enableGUI=false;
     900    if(GetMainWindow())
     901        enableGUI=true;
     902    else
     903        enableGUI=false;
    879904
     905VERBOSE(VB_GENERAL, enableGUI);
    880906    int sleepTime = GetNumSetting("WOLbackendReconnectWaitTime", 0);
    881907    int maxConnTry = GetNumSetting("WOLbackendConnectRetry", 1);
    882908
     
    914940                        manageLock = true;
    915941                        d->serverSockLock.unlock();
    916942                    }
    917                     MythPopupBox::showOkPopup(d->mainWindow,
     943                    if (GetMainWindow())
     944                        MythPopupBox::showOkPopup(d->mainWindow,
    918945                                              "connection failure",
    919946                                              tr("Could not connect to the "
    920947                                                 "master backend server -- is "
     
    930957            }
    931958            else
    932959            {
     960                if (GetMainWindow())
     961                {
     962                    busy = new MythBusyDialog(QObject::tr("Waiting for Server..."));
     963                    busy->start(1);
     964                }
     965
    933966                VERBOSE(VB_GENERAL, "Trying to wake up the MasterBackend "
    934967                                    "now.");
    935968                QString wol_cmd = GetSetting("WOLbackendCommand",
     
    937970                                             "WakeServerCommand now, if "
    938971                                             "set!\'");
    939972                system(wol_cmd.ascii());
    940 
    941                 VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds until I "
    942                                             "try to reconnect again.")
     973                cout << wol_cmd.ascii();
     974               
     975                VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds before I send wake command again.")
    943976                                            .arg(sleepTime));
    944                 sleep(sleepTime);
     977               
     978                int sleepCount = 0;
     979                serverSock = new MythSocket();               
     980                while (!serverSock->connect(hostname, port))
     981                {
     982                    sleep(1);
     983                    sleepCount++;
     984                    if (sleepCount > sleepTime)
     985                        break;
     986                }
     987                serverSock->DownRef();
     988                serverSock = NULL;                       
    945989                ++cnt;
     990                if (GetMainWindow())
     991                    busy->Close();
    946992            }
    947993            d->attemptingToConnect = false;
    948994        }