From b1098712771ab823042fcf8614a706c76c2ff401 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sun, 22 Oct 2017 02:27:25 +0100 Subject: Convert GetMaxFds() to size_t and deduplicate setting code. --- include/socketengine.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'include/socketengine.h') diff --git a/include/socketengine.h b/include/socketengine.h index fa2f26358..34dd306ba 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -266,20 +266,23 @@ class CoreExport SocketEngine **/ static std::vector ref; - protected: - /** Current number of descriptors in the engine - */ + /** Current number of descriptors in the engine. */ static size_t CurrentSetSize; + + /** The maximum number of descriptors in the engine. */ + static size_t MaxSetSize; + /** List of handlers that want a trial read/write */ static std::set trials; - static int MAX_DESCRIPTORS; - /** Socket engine statistics: count of various events, bandwidth usage */ static Statistics stats; + /** Look up the fd limit using rlimit. */ + static void LookupMaxFds(); + static void OnSetEvent(EventHandler* eh, int old_mask, int new_mask); /** Add an event handler to the base socket engine. AddFd(EventHandler*, int) should call this. @@ -344,10 +347,10 @@ public: /** Returns the number of file descriptors reported by the system this program may use * when it was started. - * @return If positive, the number of file descriptors that the system reported that we - * may use. Otherwise (<= 0) this number could not be determined. + * @return If non-zero the number of file descriptors that the system reported that we + * may use. */ - static int GetMaxFds() { return MAX_DESCRIPTORS; } + static size_t GetMaxFds() { return MaxSetSize; } /** Returns the number of file descriptors being queried * @return The set size -- cgit v1.3.1-10-gc9f91