commit 539b6353114e95fa805f55c36562502eec76534e Author: Damian Johnson atagar@torproject.org Date: Fri Jan 2 12:27:02 2015 -0800
Make proc connenction resolution more resilient
On busy relays we can fail due to descriptors being dropped in the middle of reading them. This was caught by toralf on...
https://trac.torproject.org/projects/tor/ticket/14048 --- docs/change_log.rst | 1 + stem/util/proc.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/docs/change_log.rst b/docs/change_log.rst index cad1f32..3f8a4bc 100644 --- a/docs/change_log.rst +++ b/docs/change_log.rst @@ -44,6 +44,7 @@ The following are only available within Stem's `git repository * **Utilities**
* :func:`stem.util.connection.port_usage` always returned None (:trac:`14046`) + * Proc connection resolution could fail on especially busy systems (:trac:`14048`)
.. _version_1.3:
diff --git a/stem/util/proc.py b/stem/util/proc.py index c7cb5ce..85585b4 100644 --- a/stem/util/proc.py +++ b/stem/util/proc.py @@ -365,9 +365,12 @@ def connections(pid):
if fd_name.startswith('socket:['): inodes.append(fd_name[8:-1]) - except OSError: + except OSError as exc: + if not os.path.exists(fd_path): + continue # descriptors may shift while we're in the middle of iterating over them + # most likely couldn't be read due to permissions - exc = IOError('unable to determine file descriptor destination: %s' % fd_path) + exc = IOError('unable to determine file descriptor destination (%s): %s' % (exc, fd_path)) _log_failure(parameter, exc) raise exc
tor-commits@lists.torproject.org