Ticket #3279: backend_connect.diff

File backend_connect.diff, 2.9 KB (added by devel@…, 17 years ago)

Mythcontext server reconnect improvements

  • mythtv/libs/libmyth/mythcontext.cpp

     
    877877                                       bool blockingClient)
    878878{
    879879    MythSocket *serverSock = NULL;
     880    MythBusyDialog *busy = NULL;
    880881    int cnt = 1;
     882   
     883    bool enableGUI=false;
     884    if(GetMainWindow())
     885        enableGUI=true;
     886    else
     887        enableGUI=false;
    881888
     889VERBOSE(VB_GENERAL, enableGUI);
    882890    int sleepTime = GetNumSetting("WOLbackendReconnectWaitTime", 0);
    883891    int maxConnTry = GetNumSetting("WOLbackendConnectRetry", 1);
    884892
     
    916924                        manageLock = true;
    917925                        d->serverSockLock.unlock();
    918926                    }
    919                     MythPopupBox::showOkPopup(d->mainWindow,
     927                    if (GetMainWindow())
     928                        MythPopupBox::showOkPopup(d->mainWindow,
    920929                                              "connection failure",
    921930                                              tr("Could not connect to the "
    922931                                                 "master backend server -- is "
     
    932941            }
    933942            else
    934943            {
     944                if (GetMainWindow())
     945                {
     946                    busy = new MythBusyDialog(QObject::tr("Waiting for Server..."));
     947                    busy->start(1);
     948                }
     949
    935950                VERBOSE(VB_GENERAL, "Trying to wake up the MasterBackend "
    936951                                    "now.");
    937952                QString wol_cmd = GetSetting("WOLbackendCommand",
     
    939954                                             "WakeServerCommand now, if "
    940955                                             "set!\'");
    941956                system(wol_cmd.ascii());
    942 
    943                 VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds until I "
    944                                             "try to reconnect again.")
     957                cout << wol_cmd.ascii();
     958               
     959                VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds before I send wake command again.")
    945960                                            .arg(sleepTime));
    946                 sleep(sleepTime);
     961               
     962                int sleepCount = 0;
     963                serverSock = new MythSocket();               
     964                while (!serverSock->connect(hostname, port))
     965                {
     966                    sleep(1);
     967                    sleepCount++;
     968                    if (sleepCount > sleepTime)
     969                        break;
     970                }
     971                serverSock->DownRef();
     972                serverSock = NULL;                       
    947973                ++cnt;
     974                if (GetMainWindow())
     975                    busy->Close();
    948976            }
    949977            d->attemptingToConnect = false;
    950978        }