-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Internal Code
-
None
-
Service Arch
-
Fully Compatible
-
Service Arch 2024-03-04, Service Arch 2024-03-18, Service Arch 2024-04-01
The structure is used to map operation ids to MozJS scopes, and is modified to register and unregister operations:
class MozJSScriptEngine final : public mongo::ScriptEngine { ... Mutex _globalInterruptLock = MONGO_MAKE_LATCH("MozJSScriptEngine::_globalInterruptLock"); using OpIdToScopeMap = stdx::unordered_map<unsigned, MozJSImplScope*>; OpIdToScopeMap _opToScopeMap; ... };
We can remove this map and instead, augment each operation with a decoration that holds the MozJS scope (if registered).
const auto d = OperationContext::declareDecoration<MozJSImplScope*>();
Depending on the read/write semantics for this decoration, we may choose one of the following:
- If it's only set/unset on the Client thread that owns the operation, then we can use the Client lock for synchronization.
- Otherwise, we can use synchronized_value<MozJSImplScope*> as the decoration type to ensure it's not modified while being accessed for interruption.
We can use a LockedClientCursor to navigate through all clients and interrupt their operations if needed.
- causes
-
SERVER-89726 Coverity analysis defect 152388: Dereference after null check
- Closed