[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Calling QUIT prior to disconnecting socket
commit e2528b85f6b0bf1fb82c42599e71d1c925fcd6ae
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Mon Jul 23 10:09:38 2012 -0700
Calling QUIT prior to disconnecting socket
Making the Controller's close() method try to be a nice controller by issuing a
QUIT call before detaching the socket. This is a best-effort call (errors
ignored) since the caller just wants the socket shut down and we don't need the
QUIT to succeed to do that. Original change by gsathya and discussed on...
https://trac.torproject.org/6234
---
stem/control.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/stem/control.py b/stem/control.py
index d687e1a..16bcb10 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -454,6 +454,14 @@ class Controller(BaseController):
from_port = staticmethod(from_port)
from_socket_file = staticmethod(from_socket_file)
+ def close(self):
+ # making a best-effort attempt to quit before detaching the socket
+ if self.is_alive():
+ try: self.msg("QUIT")
+ except: pass
+
+ super(Controller, self).close()
+
def get_info(self, param, default = UNDEFINED):
"""
Queries the control socket for the given GETINFO option. If provided a
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits