[tor-bugs] #6234 [Stem]: stem.socket.ControlSocket.is_alive() should check if socket is open explicitly
Tor Bug Tracker & Wiki
torproject-admin at torproject.org
Wed Jun 27 14:56:59 UTC 2012
#6234: stem.socket.ControlSocket.is_alive() should check if socket is open
explicitly
------------------------+---------------------------------------------------
Reporter: gsathya | Owner: atagar
Type: defect | Status: needs_information
Priority: normal | Milestone:
Component: Stem | Version:
Resolution: | Keywords:
Parent: | Points:
Actualpoints: |
------------------------+---------------------------------------------------
Comment(by atagar):
That makes sense. The is_alive() method works as follows...
- is_alive() simply provides the cached is_alive status (ie, what do we
think we are?)
- our is_alive flag toggles when connect() or close() is called
- our close() is called when we attempt to read from our socket and it
reports that the socket is closed
So, when you call 'QUIT' the controller sends the message, receives an OK
reply then returns to the caller. Meanwhile the reader loop pulls the
socket again and (possibly delayed by tor or the os) sees that our socket
is shut down and calls close() to clean up.
Obviously to make the 'QUIT' case work we could simply call close()
ourselves before returning. It would be a bug if our is_alive() state
didn't change for a significant amount of time, but is_alive() just
reflects 'do I seem to be alive at this instant'. We could acquire the
read lock to narrow the gap, but that doesn't seem like a good idea and
wouldn't completely eliminate this "'QUIT' -> is_alive() is false" gap.
So in summary, I think that having our quit() method call close() is
probably the best option. Let me know if you strongly disagree.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/6234#comment:10>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list