summaryrefslogtreecommitdiff
path: root/src/mongo/db/operation_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/operation_context.h')
-rw-r--r--src/mongo/db/operation_context.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h
index be234281d8b..ec3d01f4133 100644
--- a/src/mongo/db/operation_context.h
+++ b/src/mongo/db/operation_context.h
@@ -588,6 +588,19 @@ public:
*/
void restoreMaxTimeMS();
+ /**
+ * Returns whether this operation must run in read-only mode.
+ *
+ * If the read-only flag is set on the ServiceContext then:
+ * - Internal operations are allowed to perform writes.
+ * - User originating operations are not allowed to perform writes.
+ */
+ bool readOnly() const {
+ if (!getClient()->isFromUserConnection())
+ return false;
+ return !getServiceContext()->userWritesAllowed();
+ }
+
private:
StatusWith<stdx::cv_status> waitForConditionOrInterruptNoAssertUntil(
stdx::condition_variable& cv, BasicLockableAdapter m, Date_t deadline) noexcept override;