brbzull0 commented on code in PR #13543:
URL: https://github.com/apache/trafficserver/pull/13543#discussion_r3776895907
##########
src/iocore/net/UnixNet.cc:
##########
@@ -41,20 +41,12 @@ std::atomic<bool> net_memory_throttle = false;
int fds_throttle;
ink_hrtime last_transient_accept_error;
-namespace
-{
-/// Config members that @c NetHandler::configure_per_thread_values reads.
-constexpr unsigned long long PER_THREAD_DEPENDENT_CONFIG{0x3};
-// std::bitset silently discards bits at or above its width, which would drop a
-// member from the set without any diagnostic if Config ever shrinks. The first
-// assertion keeps the shift in the second one well defined.
-static_assert(NetHandler::CONFIG_ITEM_COUNT < std::numeric_limits<unsigned
long long>::digits);
-static_assert(PER_THREAD_DEPENDENT_CONFIG < (1ULL <<
NetHandler::CONFIG_ITEM_COUNT));
-} // end anonymous namespace
-
NetHandler::Config
NetHandler::global_config;
std::bitset<std::numeric_limits<unsigned int>::digits>
NetHandler::active_thread_types;
-const std::bitset<NetHandler::CONFIG_ITEM_COUNT>
NetHandler::config_value_affects_per_thread_value{PER_THREAD_DEPENDENT_CONFIG};
+/// The values @c NetHandler::configure_per_thread_values reads.
+const std::bitset<NetHandler::CONFIG_ITEM_COUNT>
NetHandler::config_value_affects_per_thread_value{
+ (1U << static_cast<unsigned>(NetHandler::Config::Index::MAX_CONNECTIONS_IN))
|
+ (1U << static_cast<unsigned>(NetHandler::Config::Index::MAX_REQUESTS_IN))};
Review Comment:
Took the 1ULL half . std::bitset's constructor takes unsigned long long
anyway, so that's the right type to build the mask in.
I left out the static_assert. The case it guards is std::bitset silently
dropping bits above its width, but that can't happen here anymore: the shift
amounts are Config::Index enumerators, and every enumerator is by construction
less than COUNT, which is exactly the width of the bitset (CONFIG_ITEM_COUNT).
So the set bits are always in range.
That guard did earn its place in #13533, where the mask was a magic 0x3 with
no connection to the struct it described and nothing tying the two together.
Deriving the mask from named indices is what makes it redundant, so keeping it
would preserve scaffolding for a problem the change removes. Happy to add it
back if you'd rather have the belt and braces.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]