-
Type: Task
-
Resolution: Won't Do
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Server Programmability
I am told there is only one ServiceContext instance in the server, but OperationContext::getServiceContext()'s implemenation implies there is a separate one per client and that at times (whenever Client* OperationContext::_client == nullptr) you might not have access to any ServiceContext. Also, you do not always have access to an OperationContext instance, so if you are dependent on it to find the ServiceContext, again there are situations where it seems like you cannot access it.
But there is a getGlobalServiceContext() function that gets the (supposedly one and only) ServiceContext instance that exists.
Can we eliminate this confusion by making OperationContext::getServiceContext() just delegate to getGlobalServiceContext(), or is the analysis above incorrect? Current implementation (operation_context.h):
/** * Returns the service context under which this operation context runs, or nullptr if there is * no such service context. */ ServiceContext* getServiceContext() const { if (!_client) { return nullptr; } return _client->getServiceContext(); }
Alternatively we could delete OperationContext::getServiceContext() and replace all current calls with getGlobalServiceContext(), but there are a huge number of existing calls (on the order of 1,000).