summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth/user_cache_invalidator_job.cpp
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2018-05-14 10:49:21 -0400
committerBilly Donahue <billy.donahue@mongodb.com>2018-05-15 13:05:33 -0400
commitdf4b551101995817b71a47ec85d58190d069540a (patch)
tree5adda3290655b19428a6d90813bddae0620f5cf6 /src/mongo/db/auth/user_cache_invalidator_job.cpp
parenta21671327a148a84c2246437f7f3c3367838855e (diff)
downloadmongo-df4b551101995817b71a47ec85d58190d069540a.tar.gz
SERVER-34345 replace ...WITH_VALIDATOR macros to ->withValidator syntax.
metaprogramming compactness mark unused auto pointer change is_same value use from {} to ::value
Diffstat (limited to 'src/mongo/db/auth/user_cache_invalidator_job.cpp')
-rw-r--r--src/mongo/db/auth/user_cache_invalidator_job.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/mongo/db/auth/user_cache_invalidator_job.cpp b/src/mongo/db/auth/user_cache_invalidator_job.cpp
index 8d6a690f19e..33b247af580 100644
--- a/src/mongo/db/auth/user_cache_invalidator_job.cpp
+++ b/src/mongo/db/auth/user_cache_invalidator_job.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/server_parameters.h"
+#include "mongo/platform/compiler.h"
#include "mongo/rpc/get_status_from_command_result.h"
#include "mongo/s/grid.h"
#include "mongo/stdx/mutex.h"
@@ -60,35 +61,35 @@ Date_t lastInvalidationTime;
class ExportedInvalidationIntervalParameter
: public ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime> {
+ using Base = ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime>;
+
public:
ExportedInvalidationIntervalParameter()
- : ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime>(
- ServerParameterSet::getGlobal(),
- "userCacheInvalidationIntervalSecs",
- &userCacheInvalidationIntervalSecs) {}
-
- virtual Status validate(const int& potentialNewValue) {
- if (potentialNewValue < 1 || potentialNewValue > 86400) {
- return Status(ErrorCodes::BadValue,
- "userCacheInvalidationIntervalSecs must be between 1 "
- "and 86400 (24 hours)");
- }
- return Status::OK();
- }
+ : Base(ServerParameterSet::getGlobal(),
+ "userCacheInvalidationIntervalSecs",
+ &userCacheInvalidationIntervalSecs) {}
- // Without this the compiler complains that defining set(const int&)
- // hides set(const BSONElement&)
- using ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime>::set;
+ // Don't hide Base::set(const BSONElement&)
+ using Base::set;
- virtual Status set(const int& newValue) {
+ Status set(const int& newValue) override {
stdx::unique_lock<stdx::mutex> lock(invalidationIntervalMutex);
- Status status =
- ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime>::set(newValue);
+ Status status = Base::set(newValue);
invalidationIntervalChangedCondition.notify_all();
return status;
}
-
-} exportedIntervalParam;
+};
+
+MONGO_COMPILER_VARIABLE_UNUSED auto _exportedInterval =
+ (new ExportedInvalidationIntervalParameter())
+ -> withValidator([](const int& potentialNewValue) {
+ if (potentialNewValue < 1 || potentialNewValue > 86400) {
+ return Status(ErrorCodes::BadValue,
+ "userCacheInvalidationIntervalSecs must be between 1 "
+ "and 86400 (24 hours)");
+ }
+ return Status::OK();
+ });
StatusWith<OID> getCurrentCacheGeneration(OperationContext* opCtx) {
try {