Show
Ignore:
Timestamp:
01/13/06 23:32:35 (3 years ago)
Author:
edmanm
Message:

Use QAbstractSocket's isValid() method to determine if the control socket is
connected;
Check if the socket is ready for reading and writing before sending or
receiving;
Update the control test code for the method names I changed back in revision
75;
The authenticate() method in TorControl? will handle loading controller
authentication tokens itself, once it's implemented. (maybe)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/control/controlconnection.cpp

    r61 r84  
    5757{ 
    5858  disconnectFromHost(); 
    59   if (!waitForDisconnected(-1)) { 
    60     if (errmsg) { 
    61       *errmsg = 
    62         QString("Error disconnecting socket. [%1]").arg(errorString()); 
     59  if (state() != QAbstractSocket::UnconnectedState) { 
     60    if (!waitForDisconnected(-1)) { 
     61      if (errmsg) { 
     62        *errmsg = 
     63          QString("Error disconnecting socket. [%1]").arg(errorString()); 
     64      } 
     65      return false; 
    6366    } 
    64     return false; 
    6567  } 
    6668  return true; 
     
    7779ControlConnection::sendCommand(ControlCommand cmd, QString *errmsg) 
    7880{ 
     81  if (!isValid()) { 
     82    return false; 
     83  } 
     84   
    7985  /* Format the control command */ 
    8086  QString strCmd = cmd.toString(); 
     
    109115  QChar c; 
    110116  QString line; 
     117 
     118  if (!isValid()) { 
     119    return false; 
     120  } 
    111121 
    112122  /* The implementation below is based on the Java control library from Tor */