[mythtv] [PATCH] Add single retry of connection to master backend

Allan Stirling Dibblahmythml0015 at pendor.org
Fri Jun 3 11:12:03 UTC 2005


If the master backend is restarted, the frontend presents an error ("The 
connection to the master backend server has gone away for some 
reason..") to the user. This is probably unnecessary, since a retry will 
fix the situation.

The only reason I see not to change this code is so the end-user is 
notified when the backend is restarted. However, in a non-development 
environment (where WAF is concerned),  the dialog doesn't exactly add value.

The attached patch adds a single retry of the connection. It also cleans 
up the function somewhat - The "// this should be obsolete..." section 
has been around since December 2003.

I don't see the associated cerr in any of my logs. If this is incorrect, 
I'll resubmit the patch with just the functional changes.

Cheers,

Allan.

-------------- next part --------------
Index: libs/libmyth/mythcontext.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcontext.cpp,v
retrieving revision 1.179
diff -u -r1.179 mythcontext.cpp
--- libs/libmyth/mythcontext.cpp	1 Jun 2005 21:09:54 -0000	1.179
+++ libs/libmyth/mythcontext.cpp	3 Jun 2005 10:41:27 -0000
@@ -1995,40 +1995,33 @@
 
 bool MythContext::SendReceiveStringList(QStringList &strlist, bool quickTimeout)
 {
+    bool ok = false;
+
     d->serverSockLock.lock();
     
     if (!d->serverSock)
         ConnectToMasterServer();
 
-    bool ok = false;
-    
     if (d->serverSock)
     {
         WriteStringList(d->serverSock, strlist);
         ok = ReadStringList(d->serverSock, strlist, quickTimeout);
 
-        // this should be obsolete...
-        while (ok && strlist[0] == "BACKEND_MESSAGE")
+        if (!ok)
         {
-            // oops, not for us
-            cerr << "SRSL you shouldn't see this!!";
-            QString message = strlist[1];
-            QString extra = strlist[2];
-
-            MythEvent me(message, extra);
-            dispatch(me);
-
+            VERBOSE(VB_IMPORTANT, QString("Connection to backend server lost"));
+            ConnectToMasterServer();
+            WriteStringList(d->serverSock, strlist);
             ok = ReadStringList(d->serverSock, strlist, quickTimeout);
         }
-        // .
 
         if (!ok)
         {
             qApp->lock();
-            VERBOSE(VB_ALL, QString("Connection to backend server lost"));
+            VERBOSE(VB_IMPORTANT, QString("Reconnection to backend server failed"));
             MythPopupBox::showOkPopup(d->mainWindow, "connection failure",
                              tr("The connection to the master backend "
-                                "server has gone away for some reason.. "
+                                "server has failed. "
                                 "Is it running?"));
 
             delete d->serverSock;


More information about the mythtv-dev mailing list