[tor-bugs] #2812 [Torctl]: TorCtl Zombie Connections
Tor Bug Tracker & Wiki
torproject-admin at torproject.org
Tue Mar 29 16:22:27 UTC 2011
#2812: TorCtl Zombie Connections
--------------------+-------------------------------------------------------
Reporter: atagar | Owner:
Type: defect | Status: needs_review
Priority: normal | Milestone:
Component: Torctl | Version:
Keywords: | Parent:
Points: | Actualpoints:
--------------------+-------------------------------------------------------
Comment(by atagar):
Pesky. The proper solution is to add 'self._s.shutdown(socket.SHUT_RDWR)'
prior to the close in TorUtil.BufSocket. That is to say...
Index: src/TorCtl/TorUtil.py
===================================================================
--- src/TorCtl/TorUtil.py (revision 24405)
+++ src/TorCtl/TorUtil.py (working copy)
@@ -221,6 +221,7 @@
self._s.send(s)
def close(self):
+ self._s.shutdown(socket.SHUT_RDWR)
self._s.close()
# SocketServer.TCPServer is nuts..
Index: src/TorCtl/TorCtl.py
===================================================================
--- src/TorCtl/TorCtl.py (revision 24499)
+++ src/TorCtl/TorCtl.py (working copy)
@@ -109,7 +109,7 @@
than prompting the user)
"""
- s = None
+ conn = None
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((controlAddr, controlPort))
@@ -133,10 +133,10 @@
print "Connection refused. Is the ControlPort enabled?"
else: print "Failed to establish socket: %s" % exc
- if s: s.shutdown(socket.SHUT_RDWR)
+ if conn: conn.close()
return None
except Exception, exc:
- if s: s.shutdown(socket.SHUT_RDWR)
+ if conn: conn.close()
if passphrase and str(exc) == "Unable to authenticate: password
incorrect":
# provide a warning that the provided password didn't work, then
try
===================================================================
In general this works fine, except that when I try to join on
TorCtl.Connection._thread after the close() it runs into deadlock
(evidently this change means that _loop never terminates, my guess is that
_read_reply() is blocking).
I'm not quite sure of the proper workaround for this. The earlier fix
addresses the issue I'm primarily concerned about with arm so I'll leave
it with that for now. -Damian
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/2812#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list