summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2016-03-10 14:54:56 -0500
committerGeert Bosch <geert@mongodb.com>2016-03-11 07:46:23 -0500
commitcbb3a09da470edae68fca624cca880582491a782 (patch)
tree02a3f5b576f63d729568c6b411f09cef4e2cb253
parent7ed2327abb1168d7f89e3cd05c8740eee20dcdde (diff)
downloadmongo-cbb3a09da470edae68fca624cca880582491a782.tar.gz
SERVER-23066 Make killOp accept negative opid
-rw-r--r--src/mongo/db/commands/kill_op.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/db/commands/kill_op.cpp b/src/mongo/db/commands/kill_op.cpp
index bd0555b9364..baaf8106220 100644
--- a/src/mongo/db/commands/kill_op.cpp
+++ b/src/mongo/db/commands/kill_op.cpp
@@ -81,6 +81,12 @@ public:
log() << "going to kill op: " << op;
result.append("info", "attempting to kill op");
+ // Internally opid is an unsigned 32-bit int, but as BSON only has signed integer types,
+ // we wrap values exceeding 2,147,483,647 to negative numbers. The following undoes this
+ // transformation, so users can use killOp on the (negative) opid they received.
+ if (op >= std::numeric_limits<int>::min() && op < 0)
+ op += 1ull << 32;
+
uassert(26823,
str::stream() << "invalid op : " << op,
(op >= 0) && (op <= std::numeric_limits<unsigned int>::max()));