Ticket #3279: backend_connect.diff
File backend_connect.diff, 2.9 KB (added by , 17 years ago) |
---|
-
mythtv/libs/libmyth/mythcontext.cpp
877 877 bool blockingClient) 878 878 { 879 879 MythSocket *serverSock = NULL; 880 MythBusyDialog *busy = NULL; 880 881 int cnt = 1; 882 883 bool enableGUI=false; 884 if(GetMainWindow()) 885 enableGUI=true; 886 else 887 enableGUI=false; 881 888 889 VERBOSE(VB_GENERAL, enableGUI); 882 890 int sleepTime = GetNumSetting("WOLbackendReconnectWaitTime", 0); 883 891 int maxConnTry = GetNumSetting("WOLbackendConnectRetry", 1); 884 892 … … 916 924 manageLock = true; 917 925 d->serverSockLock.unlock(); 918 926 } 919 MythPopupBox::showOkPopup(d->mainWindow, 927 if (GetMainWindow()) 928 MythPopupBox::showOkPopup(d->mainWindow, 920 929 "connection failure", 921 930 tr("Could not connect to the " 922 931 "master backend server -- is " … … 932 941 } 933 942 else 934 943 { 944 if (GetMainWindow()) 945 { 946 busy = new MythBusyDialog(QObject::tr("Waiting for Server...")); 947 busy->start(1); 948 } 949 935 950 VERBOSE(VB_GENERAL, "Trying to wake up the MasterBackend " 936 951 "now."); 937 952 QString wol_cmd = GetSetting("WOLbackendCommand", … … 939 954 "WakeServerCommand now, if " 940 955 "set!\'"); 941 956 system(wol_cmd.ascii()); 942 943 VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds until I "944 "try to reconnectagain.")957 cout << wol_cmd.ascii(); 958 959 VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds before I send wake command again.") 945 960 .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; 947 973 ++cnt; 974 if (GetMainWindow()) 975 busy->Close(); 948 976 } 949 977 d->attemptingToConnect = false; 950 978 }