summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/killcursors_cmd.cpp
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2021-01-11 16:42:09 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-13 07:53:28 +0000
commit5e691b22a9ba8263662aa077a40f66f96edc2041 (patch)
tree3f191f1fc4f3d483ac3952f05d98fa507d88760e /src/mongo/db/commands/killcursors_cmd.cpp
parentb196c637c409ab9d84df96fe8f3595cea9e5b6fa (diff)
downloadmongo-5e691b22a9ba8263662aa077a40f66f96edc2041.tar.gz
SERVER-53161 Convert killCursors to TypedCommand
Diffstat (limited to 'src/mongo/db/commands/killcursors_cmd.cpp')
-rw-r--r--src/mongo/db/commands/killcursors_cmd.cpp35
1 files changed, 6 insertions, 29 deletions
diff --git a/src/mongo/db/commands/killcursors_cmd.cpp b/src/mongo/db/commands/killcursors_cmd.cpp
index 8e9aa80b0c9..675b776352e 100644
--- a/src/mongo/db/commands/killcursors_cmd.cpp
+++ b/src/mongo/db/commands/killcursors_cmd.cpp
@@ -30,44 +30,20 @@
#include "mongo/platform/basic.h"
#include "mongo/db/auth/authorization_session.h"
-#include "mongo/db/catalog/collection.h"
#include "mongo/db/commands/killcursors_common.h"
-#include "mongo/db/curop.h"
#include "mongo/db/cursor_manager.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/query/kill_cursors_gen.h"
#include "mongo/db/stats/top.h"
-#include "mongo/util/scopeguard.h"
namespace mongo {
-class KillCursorsCmd final : public KillCursorsCmdBase {
- KillCursorsCmd(const KillCursorsCmd&) = delete;
- KillCursorsCmd& operator=(const KillCursorsCmd&) = delete;
-
-public:
- KillCursorsCmd() = default;
-
- const std::set<std::string>& apiVersions() const {
- return kApiVersions1;
- }
-
- bool run(OperationContext* opCtx,
- const std::string& dbname,
- const BSONObj& cmdObj,
- BSONObjBuilder& result) final {
- return runImpl(opCtx, dbname, cmdObj, result);
- }
-
-private:
- Status _checkAuth(Client* client, const NamespaceString& nss, CursorId id) const final {
- auto opCtx = client->getOperationContext();
+struct KillCursorsCmd {
+ static constexpr bool supportsReadConcern = false;
+ static Status doCheckAuth(OperationContext* opCtx, const NamespaceString& nss, CursorId id) {
return CursorManager::get(opCtx)->checkAuthForKillCursors(opCtx, id);
}
-
- Status _killCursor(OperationContext* opCtx,
- const NamespaceString& nss,
- CursorId id) const final {
+ static Status doKillCursor(OperationContext* opCtx, const NamespaceString& nss, CursorId id) {
boost::optional<AutoStatsTracker> statsTracker;
if (!nss.isCollectionlessCursorNamespace()) {
statsTracker.emplace(opCtx,
@@ -80,6 +56,7 @@ private:
auto cursorManager = CursorManager::get(opCtx);
return cursorManager->killCursor(opCtx, id, true /* shouldAudit */);
}
-} killCursorsCmd;
+};
+KillCursorsCmdBase<KillCursorsCmd> cmdKillCursors;
} // namespace mongo