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

Re: [tor-bugs] #6234 [Stem]: stem.socket.ControlSocket.is_alive() should check if socket is open explicitly



#6234: stem.socket.ControlSocket.is_alive() should check if socket is open
explicitly
------------------------+---------------------------------------------------
    Reporter:  gsathya  |       Owner:  atagar        
        Type:  defect   |      Status:  needs_revision
    Priority:  normal   |   Milestone:                
   Component:  Stem     |     Version:                
  Resolution:           |    Keywords:                
      Parent:           |      Points:                
Actualpoints:           |  
------------------------+---------------------------------------------------
Changes (by atagar):

  * status:  needs_review => needs_revision


Comment:

 > self.msg("QUIT")

 We should check the QUIT's reply. You'll want to use Ravi's SingleLine
 response parser...

 {{{
 response = self.msg("QUIT")
 stem.response.convert("SINGLELINE", response)

 if response.is_ok():
   self.close()
 else:
   raise stem.socket.ProtocolError("The QUIT provided a non-ok response:
 %s" % response)
 }}}

 > +    with runner.get_tor_controller(False) as controller:
 > +      controller.quit()
 > +      self.assertEqual(controller._socket.is_alive(), False)
 > +      self.assertRaises(stem.socket.SocketClosed,
 controller.authenticate(test.runner.CONTROL_PASSWORD))

 Lets test with both an authenticated an unauthenticated controller.
 Amusingly this test would also work if you called
 'controller.msg("GOBBDLYGOOK")' followed by a sleep since unauthenticated
 sockets will disconnect us anyway.

 Also, please use get_socket() rather than accessing the _socket member
 directly and go back to using controller.protocolinfo() rather than
 authenticate (does the same thing and it's less verbose).

 Otherwise looks good!

 ========================================

 Slightly weird idea, but instead of adding a quit() method what about
 adding a best-effort msg("QUIT") call to our close() method instead? Both
 quit() and close() do largely the same thing, and users don't really care
 if the QUIT call succeeds or not as long as the socket is closed (we can
 add a flag if that isn't the case).

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/6234#comment:16>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs