[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r1662: Add some more logging messages that could be useful. (in trunk: . src src/control src/gui/network)



Author: edmanm
Date: 2007-03-08 15:26:10 -0500 (Thu, 08 Mar 2007)
New Revision: 1662

Modified:
   trunk/
   trunk/src/control/controlconnection.cpp
   trunk/src/control/controlsocket.cpp
   trunk/src/control/torprocess.cpp
   trunk/src/control/torservice.cpp
   trunk/src/gui/network/netviewer.cpp
   trunk/src/main.cpp
Log:
 r1716@adrastea:  edmanm | 2007-03-08 15:21:50 -0500
 Add some more logging messages that could be useful.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /vidalia/local/trunk [r1716] on 54b3572a-7227-0410-958f-53ecd705b71a

Modified: trunk/src/control/controlconnection.cpp
===================================================================
--- trunk/src/control/controlconnection.cpp	2007-03-08 19:26:36 UTC (rev 1661)
+++ trunk/src/control/controlconnection.cpp	2007-03-08 20:26:10 UTC (rev 1662)
@@ -78,14 +78,18 @@
   for (int i = 0; i < MAX_CONNECT_ATTEMPTS; i++) {
     /* Check if we're supposed to cancel our attempt to connect */
     if (status() != Connecting) {
+      vNotice("Cancelling attempt to connect to Tor's control port.");
       return false;
     }
     
     /* Try to connect */
     _connMutex.lock();
+    vDebug("Control connection attempt %1 of %2").arg(i+1)
+                                                  .arg(MAX_CONNECT_ATTEMPTS);
     result = _sock->connect(_addr, _port, &errmsg); 
     _connMutex.unlock();
     if (result) {
+      vInfo("Connected to Tor's control port.");
       setStatus(Connected);
       emit connected();
       return true;
@@ -93,6 +97,9 @@
     QThread::usleep(CONNECT_RETRY_DELAY);
   }
   setStatus(Disconnected);
+  vWarn("Failed to connect to Tor's control port after %1 attempts: %2")
+                                                      .arg(MAX_CONNECT_ATTEMPTS)
+                                                      .arg(errmsg);
   emit connectFailed(errmsg);
   return false;
 }
@@ -263,8 +270,10 @@
   
   /* Attempt to connect to Tor */
   if (connect()) {
+    vDebug("Starting control connection event loop.");
     /* Kick off the event loop */
     exec();
+    vDebug("Exited control connection event loop.");
   }
   
   /* Update the connection status */

Modified: trunk/src/control/controlsocket.cpp
===================================================================
--- trunk/src/control/controlsocket.cpp	2007-03-08 19:26:36 UTC (rev 1661)
+++ trunk/src/control/controlsocket.cpp	2007-03-08 20:26:10 UTC (rev 1662)
@@ -27,6 +27,7 @@
 
 #include <QHostAddress>
 #include <util/string.h>
+#include <vidalia.h>
 
 #include "controlsocket.h"
 
@@ -55,8 +56,11 @@
   ProtocolVersion version;
 
   /* Connect the control socket. */
+  vNotice("Connecting to Tor's control port on %1:%2").arg(addr.toString())
+                                                      .arg(port);
   connectToHost(addr, port);
   if (!waitForConnected(CONN_TIMEOUT)) {
+    vWarn("Failed to connect to Tor's control port: %1").arg(errorString());
     return err(errmsg, tr("Error connecting to %1:%2 [%3]")
                                             .arg(addr.toString())
                                             .arg(port)
@@ -69,6 +73,7 @@
   blockSignals(false);
   if (version != Version1) {
     disconnect();
+    vWarn("Unsupported Tor protocol version '%1'").arg(version);
     if (version == VersionUnknown) {
       return err(errmsg, tr("Vidalia was unable to determine Tor's control "
                             "protocol version. Verify that your control port number "
@@ -91,6 +96,7 @@
   disconnectFromHost();
   if (isConnected()) {
     if (!waitForDisconnected(CONN_TIMEOUT)) {
+      vWarn("Failed to disconnect from Tor: %1").arg(errorString());
       return err(errmsg, tr("Error disconnecting socket. [%1]")
                                             .arg(errorString()));
     }
@@ -118,6 +124,8 @@
   }
   while (bytesAvailable() < 4) {
     if (!waitForReadyRead(-1)) {
+      vWarn("Reading failed while determining control protocol version: %1")
+                                                         .arg(errorString());
       return VersionUnknown;
     }
   }

Modified: trunk/src/control/torprocess.cpp
===================================================================
--- trunk/src/control/torprocess.cpp	2007-03-08 19:26:36 UTC (rev 1661)
+++ trunk/src/control/torprocess.cpp	2007-03-08 20:26:10 UTC (rev 1662)
@@ -26,6 +26,7 @@
  */
 
 #include <QString>
+#include <vidalia.h>
 
 /* Needed for _PROCESS_INFORMATION so that pid() works on Win32 */
 #if defined (Q_OS_WIN32)
@@ -57,10 +58,12 @@
    * quoted before being passed to it. */
   app = "\"" + app + "\"";
 #endif
-
+  app = app + " " + args;
+  
   /* Attempt to start Tor with the given command-line arguments */
   setEnvironment(QProcess::systemEnvironment());
-  QProcess::start(app + " " + args, QIODevice::ReadOnly | QIODevice::Text);
+  vNotice("Starting Tor using '%1'").arg(app);
+  QProcess::start(app, QIODevice::ReadOnly | QIODevice::Text);
 }
 
 /** Stops the Tor process */
@@ -73,6 +76,7 @@
     return true;
   }
 
+  vNotice("Stopping the Tor process.");
   /* Tell the process to stop */
 #if defined(Q_OS_WIN32)
   /* Tor on Windows doesn't understand a WM_CLOSE message (which is what 
@@ -83,6 +87,7 @@
 
   /* Wait for it to complete */
   if (!waitForFinished(-1)) {
+    vWarn("Tor failed to stop: %1").arg(errorString());
     if (errmsg) {
       *errmsg = 
         tr("Process %1 failed to stop. [%2]").arg(pid()).arg(errorString());
@@ -151,8 +156,11 @@
 TorProcess::onError(QProcess::ProcessError error)
 {
   if (error == QProcess::FailedToStart) {
+    vWarn("The Tor process failed to start: %1").arg(errorString());
     /* Tor didn't start, so let everyone know why. */
     emit startFailed(errorString());
+  } else {
+    vWarn("Tor process error: %1").arg(errorString());
   }
 }
 

Modified: trunk/src/control/torservice.cpp
===================================================================
--- trunk/src/control/torservice.cpp	2007-03-08 19:26:36 UTC (rev 1661)
+++ trunk/src/control/torservice.cpp	2007-03-08 20:26:10 UTC (rev 1662)
@@ -26,6 +26,7 @@
  */
 
 #include <QLibrary>
+#include <vidalia.h>
 
 #include "torservice.h"
 
@@ -69,6 +70,7 @@
 #define LOAD_SERVICE_FN(f) do {                                         \
   void *fn;                                                             \
   if (!((fn = QLibrary::resolve("advapi32", #f)))) {                    \
+      vWarn("Unable to load NT service function: %1").arg(#f);          \
       return false;                                                     \
     } else {                                                            \
       _service_fns.f = (f ## _fn) fn;                                   \
@@ -149,6 +151,7 @@
   SC_HANDLE service = openService();
 
   if (!service) {
+    vWarn("Bug: We tried to start the Tor service, but it is not installed.");
     emit startFailed(tr("The Tor service is not installed."));
     return;
   }
@@ -156,6 +159,7 @@
   /* Starting a service can take up to 30 seconds! */
   if (status() != SERVICE_RUNNING) {
     int tries = 0;
+    vNotice("Starting the Tor service.");
     _service_fns.StartServiceA(service, 0, NULL);
 
     while ((status() != SERVICE_RUNNING) && ++tries <= 5)
@@ -165,7 +169,8 @@
   if (status() == SERVICE_RUNNING) {
     emit started();
   } else {
-    emit startFailed(tr("Unable to start Tor service."));
+    vWarn("Unable to start the Tor service.");
+    emit startFailed(tr("Unable to start the Tor service."));
   }
   closeHandle(service);
 }
@@ -182,6 +187,7 @@
   if (status() != SERVICE_STOPPED) {
     SERVICE_STATUS stat;
     stat.dwCurrentState = SERVICE_RUNNING;
+    vNotice("Stopping the Tor service.");
     if (_service_fns.ControlService(service, SERVICE_CONTROL_STOP, &stat)) {
       /* XXX Five seconds isn't long enough to wait when we're stopping a Tor
        * that is running as a server, but we don't want to block for 30
@@ -199,6 +205,8 @@
     emit finished(exitCode(), exitStatus());
     return true;
   }
+  /* XXX This needs an actual reason message. */
+  vWarn("Unable to stop the Tor service.");
   return false;
 }
 
@@ -255,14 +263,19 @@
                                                  .arg(torrc)
                                                  .arg(controlPort);
 
+    vNotice("Installing the Tor service using the command line '%1'")
+                                                        .arg(command);
     service = _service_fns.CreateServiceA(_scm, 
                               (LPCTSTR)TOR_SERVICE_NAME, (LPCTSTR)TOR_SERVICE_DISP,
                               TOR_SERVICE_ACCESS, SERVICE_WIN32_OWN_PROCESS,
                               SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
                               (LPCTSTR)command.toAscii().data(), NULL, NULL, NULL, 
                               NULL, NULL);
-    if (!service)
+    if (!service) {
+      /* XXX This needs an actual reason message. */
+      vWarn("Failed to install the Tor service.");
       return false;
+    }
 
     SERVICE_DESCRIPTION desc;
     desc.lpDescription = TOR_SERVICE_DESC;
@@ -283,9 +296,14 @@
 
   if (service) {
     stop();
+    vNotice("Removing the Tor service.");
     removed = _service_fns.DeleteService(service);
     closeHandle(service);
   }
+  if (!removed) {
+    /* XXX This needs an actual reason message. */
+    vWarn("Failed to remove the Tor service.");
+  }
   return removed;
 }
 

Modified: trunk/src/gui/network/netviewer.cpp
===================================================================
--- trunk/src/gui/network/netviewer.cpp	2007-03-08 19:26:36 UTC (rev 1661)
+++ trunk/src/gui/network/netviewer.cpp	2007-03-08 20:26:10 UTC (rev 1662)
@@ -261,7 +261,9 @@
 {
   /* Get descriptors for all the given IDs */
   QList<RouterDescriptor> rds = _torControl->getDescriptorListById(ids);
-   
+  
+  vInfo("Loading %1 server descriptors for the network map.")
+                                             .arg(rds.size());
   foreach (RouterDescriptor rd, rds) {
     /* Load the router descriptor and add it to the router list. */
     if (!rd.isEmpty()) {
@@ -356,6 +358,8 @@
      * request is for more than a quarter of the servers in the list. */
     if (isVisible() || 
         (_resolveQueue.size() >= ui.treeRouterList->topLevelItemCount()/4)) {
+      vInfo("Sending GeoIP request for %1 IP addresses.")
+                               .arg(_resolveQueue.size());
       /* Flush the resolve queue and stop the timers */
       _geoip.resolve(_resolveQueue);
       _resolveQueue.clear();
@@ -374,7 +378,7 @@
   Q_UNUSED(id);
   QString ip;
   RouterListItem *router;
-  
+ 
   foreach (GeoIp geoip, geoips) {
     /* Find all routers that are at this IP address */
     ip = geoip.ip().toString();

Modified: trunk/src/main.cpp
===================================================================
--- trunk/src/main.cpp	2007-03-08 19:26:36 UTC (rev 1661)
+++ trunk/src/main.cpp	2007-03-08 20:26:10 UTC (rev 1662)
@@ -113,7 +113,7 @@
 
   /* Vidalia exited, so cleanup our pidfile and return */
   QFile::remove(pidfile);
-  vNotice("Exiting cleanly (return code %1).").arg(ret);
+  vNotice("Vidalia is exiting cleanly (return code %1).").arg(ret);
   return ret;
 }