commit ed1a97da1ea6c7a633fc4b7001f0fdd543d10015 Author: Damian Johnson atagar@torproject.org Date: Sun Jan 26 19:32:13 2014 -0800
Dropping tor_tools' get_my_file_descriptor_limit()
In Tor version 0.2.3.x-final we added the ability to query available tor's file descriptor limit. This method was a holdover from before this was commonly available, taking a guess at the limit based on either 'ulimit -Hn' or tor's user.
This tor capability has been out there long enough that we can drop this fallback functionality. --- arm/header_panel.py | 17 +++++++++-------- arm/util/tor_tools.py | 39 --------------------------------------- 2 files changed, 9 insertions(+), 47 deletions(-)
diff --git a/arm/header_panel.py b/arm/header_panel.py index 8621fb3..f287d81 100644 --- a/arm/header_panel.py +++ b/arm/header_panel.py @@ -75,7 +75,7 @@ class HeaderPanel(panel.Panel, threading.Thread): tor/ version, versionStatus, nickname, or_port, dir_port, control_port, socketPath, exit_policy, isAuthPassword (bool), isAuthCookie (bool), orListenAddr, *address, *fingerprint, *flags, pid, start_time, - *fd_used, fd_limit, isFdLimitEstimate + *fd_used, fd_limit sys/ hostname, os, version stat/ *%torCpu, *%armCpu, *rss, *%mem
@@ -364,8 +364,7 @@ class HeaderPanel(panel.Panel, threading.Thread): elif fd_percent >= 60: fd_percent_format = ui_tools.get_color("yellow")
- estimate_char = "?" if self.vals["tor/isFdLimitEstimate"] else "" - base_label = "file desc: %i / %i%s (" % (self.vals["tor/fd_used"], self.vals["tor/fd_limit"], estimate_char) + base_label = "file desc: %i / %i (" % (self.vals["tor/fd_used"], self.vals["tor/fd_limit"])
self.addstr(y, x + 59, base_label) self.addstr(y, x + 59 + len(base_label), fd_percentLabel, fd_percent_format) @@ -593,9 +592,12 @@ class HeaderPanel(panel.Panel, threading.Thread): # file descriptor limit for the process, if this can't be determined # then the limit is None
- fd_limit, fd_is_estimate = tor_tools.get_conn().get_my_file_descriptor_limit() - self.vals["tor/fd_limit"] = fd_limit - self.vals["tor/isFdLimitEstimate"] = fd_is_estimate + fd_limit = controller.get_info('process/descriptor-limit', '-1') + + if fd_limit != '-1' and fd_limit.isdigit(): + self.vals["tor/fd_limit"] = int(fd_limit) + else: + self.vals["tor/fd_limit"] = None
# system information
@@ -642,8 +644,7 @@ class HeaderPanel(panel.Panel, threading.Thread):
if self.vals["tor/fd_used"] and self.vals["tor/fd_limit"]: fd_percent = 100 * self.vals["tor/fd_used"] / self.vals["tor/fd_limit"] - estimated_label = " estimated" if self.vals["tor/isFdLimitEstimate"] else "" - msg = "Tor's%s file descriptor usage is at %i%%." % (estimated_label, fd_percent) + msg = "Tor's file descriptor usage is at %i%%." % fd_percent
if fd_percent >= 90 and not self._is_fd_ninety_percent_warned: self._is_fd_sixty_percent_warned, self._is_fd_ninety_percent_warned = True, True diff --git a/arm/util/tor_tools.py b/arm/util/tor_tools.py index 0e7aaec..1d17905 100644 --- a/arm/util/tor_tools.py +++ b/arm/util/tor_tools.py @@ -484,45 +484,6 @@ class Controller:
return result
- def get_my_file_descriptor_limit(self): - """ - Provides the maximum number of file descriptors this process can have. - Only the Tor process itself reliably knows this value, and the option for - getting this was added in Tor 0.2.3.x-final. If that's unavailable then - we can only estimate the file descriptor limit based on other factors. - - The return result is a tuple of the form: - (fileDescLimit, isEstimate) - and if all methods fail then both values are None. - """ - - # provides -1 if the query fails - queried_limit = self.get_info("process/descriptor-limit", None) - - if queried_limit is not None and queried_limit != "-1": - return (int(queried_limit), False) - - tor_user = self.get_my_user() - - # This is guessing the open file limit. Unfortunately there's no way - # (other than "/usr/proc/bin/pfiles pid | grep rlimit" under Solaris) - # to get the file descriptor limit for an arbitrary process. - - if tor_user == "debian-tor": - # probably loaded via /etc/init.d/tor which changes descriptor limit - return (8192, True) - else: - # uses ulimit to estimate (-H is for hard limit, which is what tor uses) - ulimit_results = system.call("ulimit -Hn") - - if ulimit_results: - ulimit = ulimit_results[0].strip() - - if ulimit.isdigit(): - return (int(ulimit), True) - - return (None, None) - def get_start_time(self): """ Provides the unix time for when the tor process first started. If this
tor-commits@lists.torproject.org