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

[vidalia-svn] r1736: Add some more verbose logging for control messsages. Also, u (in trunk: . src/control)



Author: edmanm
Date: 2007-05-13 03:24:11 -0400 (Sun, 13 May 2007)
New Revision: 1736

Modified:
   trunk/
   trunk/src/control/controlconnection.cpp
   trunk/src/control/controlsocket.cpp
Log:
 r1838@adrastea:  edmanm | 2007-05-13 03:13:26 -0400
 Add some more verbose logging for control messsages. Also, use QMutex::lock()
 and unlock() directly, instead of QMutexLocker so we can release the mutex
 before trying to wakeAll().



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

Modified: trunk/src/control/controlconnection.cpp
===================================================================
--- trunk/src/control/controlconnection.cpp	2007-05-13 07:23:57 UTC (rev 1735)
+++ trunk/src/control/controlconnection.cpp	2007-05-13 07:24:11 UTC (rev 1736)
@@ -140,20 +140,29 @@
 bool
 ControlConnection::send(ControlCommand cmd, ControlReply &reply, QString *errmsg)
 {
+  bool result = false;
+  QString errstr;
+
   _recvMutex.lock();
-  if (send(cmd, errmsg)) {
+  if (send(cmd, &errstr)) {
     /* Create and enqueue a new receive waiter */
     ReceiveWaiter *w = new ReceiveWaiter();
     _recvQueue.enqueue(w);
     _recvMutex.unlock();
 
     /* Wait for and get the result, clean up, and return */
-    bool result = w->getResult(&reply, errmsg);
+    result = w->getResult(&reply, &errstr);
+    if (!result)
+      vWarn("Failed to receive control reply: %1").arg(errstr);
     delete w;
-    return result;
+  } else {
+    vWarn("Failed to send control command: %1").arg(errstr);
+    _recvMutex.unlock();
   }
-  _recvMutex.unlock();
-  return false;
+
+  if (!result && errmsg)
+    *errmsg = errstr;
+  return result;
 }
 
 /** Sends a control command to Tor. If the current thread is not the thread
@@ -197,17 +206,22 @@
 {
   QMutexLocker locker(&_connMutex);
   ReceiveWaiter *waiter;
+  QString errmsg;
  
   while (_sock->canReadLine()) {
     ControlReply reply;
-    if (_sock->readReply(reply)) {
+    if (_sock->readReply(reply, &errmsg)) {
       if (reply.getStatus() == "650") {
         /* Asynchronous event message */
+        vDebug("Control Event: %1").arg(reply.toString());
+        
         if (_events) {
           _events->handleEvent(reply);
         }
       } else {
         /* Response to a previous command */
+        vInfo("Control Reply: %1").arg(reply.toString());
+        
         _recvMutex.lock();
         if (!_recvQueue.isEmpty()) {
           waiter = _recvQueue.dequeue();
@@ -215,6 +229,8 @@
         }
         _recvMutex.unlock();
       }
+    } else {
+      vWarn("Unable to read control reply: %1").arg(errmsg);
     }
   }
 }
@@ -328,10 +344,11 @@
                                             ControlReply reply, 
                                             QString errmsg)
 {
-  QMutexLocker locker(&_mutex);
+  _mutex.lock();
   _status = (success ? Success : Failed);
   _reply = reply; 
   _errmsg = errmsg;
+  _mutex.unlock();
   _waitCond.wakeAll();
 }
 
@@ -343,9 +360,10 @@
 void
 ControlConnection::SendWaiter::setResult(bool success, QString errmsg)
 {
-  QMutexLocker locker(&_mutex);
+  _mutex.lock();
   _status = (success ? Success : Failed);
   _errmsg = errmsg;
+  _mutex.unlock();
   _waitCond.wakeAll();
 }
 

Modified: trunk/src/control/controlsocket.cpp
===================================================================
--- trunk/src/control/controlsocket.cpp	2007-05-13 07:23:57 UTC (rev 1735)
+++ trunk/src/control/controlsocket.cpp	2007-05-13 07:24:11 UTC (rev 1736)
@@ -152,6 +152,7 @@
   
   /* Format the control command */
   QString strCmd = cmd.toString();
+  vInfo("Control Command: %1").arg(strCmd.trimmed());
 
   /* Attempt to send the command to Tor */
   if (write(strCmd.toAscii()) != strCmd.length()) {