Ticket #3279: backend-reconnect-180707.diff
| File backend-reconnect-180707.diff, 2.9 KB (added by , 18 years ago) |
|---|
-
mythtv/libs/libmyth/mythcontext.cpp
875 893 bool blockingClient) 876 894 { 877 895 MythSocket *serverSock = NULL; 896 MythBusyDialog *busy = NULL; 878 897 int cnt = 1; 898 899 bool enableGUI=false; 900 if(GetMainWindow()) 901 enableGUI=true; 902 else 903 enableGUI=false; 879 904 905 VERBOSE(VB_GENERAL, enableGUI); 880 906 int sleepTime = GetNumSetting("WOLbackendReconnectWaitTime", 0); 881 907 int maxConnTry = GetNumSetting("WOLbackendConnectRetry", 1); 882 908 … … 914 940 manageLock = true; 915 941 d->serverSockLock.unlock(); 916 942 } 917 MythPopupBox::showOkPopup(d->mainWindow, 943 if (GetMainWindow()) 944 MythPopupBox::showOkPopup(d->mainWindow, 918 945 "connection failure", 919 946 tr("Could not connect to the " 920 947 "master backend server -- is " … … 930 957 } 931 958 else 932 959 { 960 if (GetMainWindow()) 961 { 962 busy = new MythBusyDialog(QObject::tr("Waiting for Server...")); 963 busy->start(1); 964 } 965 933 966 VERBOSE(VB_GENERAL, "Trying to wake up the MasterBackend " 934 967 "now."); 935 968 QString wol_cmd = GetSetting("WOLbackendCommand", … … 937 970 "WakeServerCommand now, if " 938 971 "set!\'"); 939 972 system(wol_cmd.ascii()); 940 941 VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds until I "942 "try to reconnectagain.")973 cout << wol_cmd.ascii(); 974 975 VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds before I send wake command again.") 943 976 .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; 945 989 ++cnt; 990 if (GetMainWindow()) 991 busy->Close(); 946 992 } 947 993 d->attemptingToConnect = false; 948 994 }
