summaryrefslogtreecommitdiff
path: root/src/mongo/db/operation_context.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2016-07-27 16:19:34 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2016-07-30 09:51:14 -0400
commit8c326de66475125ce755c52d36340b52f86ac64e (patch)
tree45ba12e37ddd23212a4df1289da7ea5d0a4557b3 /src/mongo/db/operation_context.cpp
parent1af99e48949f36754e2b877f1057bdaba0b83aea (diff)
downloadmongo-8c326de66475125ce755c52d36340b52f86ac64e.tar.gz
SERVER-25050 Set maxTimeMS on OperationContext on mongos
This change makes mongos commands to retrieve the maxTimeMS from the command and set it on the OperationContext.
Diffstat (limited to 'src/mongo/db/operation_context.cpp')
-rw-r--r--src/mongo/db/operation_context.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/operation_context.cpp b/src/mongo/db/operation_context.cpp
index 58529dffedf..2a5c8814bf3 100644
--- a/src/mongo/db/operation_context.cpp
+++ b/src/mongo/db/operation_context.cpp
@@ -139,6 +139,15 @@ bool OperationContext::hasDeadlineExpired() const {
return now >= getDeadline();
}
+Milliseconds OperationContext::getRemainingMaxTimeMillis() const {
+ if (!hasDeadline()) {
+ return Milliseconds::max();
+ }
+
+ return std::max(Milliseconds{0},
+ getDeadline() - getServiceContext()->getFastClockSource()->now());
+}
+
Microseconds OperationContext::getRemainingMaxTimeMicros() const {
if (!hasDeadline()) {
return Microseconds::max();