From a02c1657dc79e5e25ed0424faa5db66ecda8c4a2 Mon Sep 17 00:00:00 2001 From: Richard Kojedzinszky Date: Sun, 13 Mar 2022 08:47:30 +0100 Subject: util: store thread assigned id in thread-local storage Fixes #2002 --- paramiko/util.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/paramiko/util.py b/paramiko/util.py index 93970289..a344915c 100644 --- a/paramiko/util.py +++ b/paramiko/util.py @@ -225,24 +225,20 @@ def mod_inverse(x, m): return u2 -_g_thread_ids = {} +_g_thread_data = threading.local() _g_thread_counter = 0 _g_thread_lock = threading.Lock() def get_thread_id(): - global _g_thread_ids, _g_thread_counter, _g_thread_lock - tid = id(threading.currentThread()) + global _g_thread_data, _g_thread_counter, _g_thread_lock try: - return _g_thread_ids[tid] - except KeyError: - _g_thread_lock.acquire() - try: + return _g_thread_data.id + except AttributeError: + with _g_thread_lock: _g_thread_counter += 1 - ret = _g_thread_ids[tid] = _g_thread_counter - finally: - _g_thread_lock.release() - return ret + _g_thread_data.id = _g_thread_counter + return _g_thread_data.id def log_to_file(filename, level=DEBUG): -- cgit v1.2.3 From 6af11051451f7c470fbf5a30299c78ba160f13bc Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Fri, 18 Mar 2022 16:40:38 -0400 Subject: Changelog re #2002, re #2003, closes #2002 --- sites/www/changelog.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 0d1fd19e..85fb1465 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -5,6 +5,10 @@ Changelog - :bug:`1963` (via :issue:`1977`) Certificate-based pubkey auth was inadvertently broken when adding SHA2 support; this has been fixed. Reported by Erik Forsberg and fixed by Jun Omae. +- :bug:`2002` (via :issue:`2003`) Switch from module-global to thread-local + storage when recording thread IDs for a logging helper; this should avoid one + flavor of memory leak for long-running processes. Catch & patch via Richard + Kojedzinszky. - :support:`1985` Add ``six`` explicitly to install-requires; it snuck into active use at some point but has only been indicated by transitive dependency on ``bcrypt`` until they somewhat-recently dropped it. This will be -- cgit v1.2.3 From 094a5e10982c7d7ef9f17fdf755d755fec9fe19b Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Fri, 18 Mar 2022 17:00:36 -0400 Subject: Cut 2.9.3 --- paramiko/_version.py | 2 +- sites/www/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/paramiko/_version.py b/paramiko/_version.py index 3ec897c5..c5f8c829 100644 --- a/paramiko/_version.py +++ b/paramiko/_version.py @@ -1,2 +1,2 @@ -__version_info__ = (2, 9, 2) +__version_info__ = (2, 9, 3) __version__ = ".".join(map(str, __version_info__)) diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 85fb1465..358b8d8e 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,7 @@ Changelog ========= +- :release:`2.9.3 <2022-03-18>` - :bug:`1963` (via :issue:`1977`) Certificate-based pubkey auth was inadvertently broken when adding SHA2 support; this has been fixed. Reported by Erik Forsberg and fixed by Jun Omae. -- cgit v1.2.3 From 239d2bd7a620be5cdaaa26f981ea72f5f55c9050 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Fri, 18 Mar 2022 17:02:18 -0400 Subject: Cut 2.10.3 --- paramiko/_version.py | 2 +- sites/www/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/paramiko/_version.py b/paramiko/_version.py index b14b6865..82bc1161 100644 --- a/paramiko/_version.py +++ b/paramiko/_version.py @@ -1,2 +1,2 @@ -__version_info__ = (2, 10, 2) +__version_info__ = (2, 10, 3) __version__ = ".".join(map(str, __version_info__)) diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index d4f716c1..067a73ba 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,7 @@ Changelog ========= +- :release:`2.10.3 <2022-03-18>` - :release:`2.9.3 <2022-03-18>` - :bug:`1963` (via :issue:`1977`) Certificate-based pubkey auth was inadvertently broken when adding SHA2 support; this has been fixed. Reported -- cgit v1.2.3