diff options
author | Peter Powell <petpow@saberuk.com> | 2017-10-22 02:27:25 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2017-10-22 19:44:45 +0100 |
commit | b1098712771ab823042fcf8614a706c76c2ff401 (patch) | |
tree | 7feb35687035b5ac6e1dd4181501400c31a54efc /include/socketengine.h | |
parent | d4414f54910aeaa4809a7eacea75a089a0820f40 (diff) |
Convert GetMaxFds() to size_t and deduplicate setting code.
Diffstat (limited to 'include/socketengine.h')
-rw-r--r-- | include/socketengine.h | 19 |
1 files changed, 11 insertions, 8 deletions
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<EventHandler*> 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<int> 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 |