Skip to content

Commit 26e29ab

Browse files
committed
refactor: Move type-context.h getParams() call closer to use
This change has no effect on behavior, it just narrows the scope of the params variable to avoid potential bugs if a cancellation happens and makes them no longer valid.
1 parent c90ae70 commit 26e29ab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/mp/type-context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ auto PassField(Priority<1>, TypeList<>, ServerContext& server_context, const Fn&
6161
std::is_same<decltype(Accessor::get(server_context.call_context.getParams())), Context::Reader>::value,
6262
kj::Promise<typename ServerContext::CallContext>>::type
6363
{
64-
const auto& params = server_context.call_context.getParams();
65-
Context::Reader context_arg = Accessor::get(params);
6664
auto& server = server_context.proxy_server;
6765
int req = server_context.req;
6866
// Keep a reference to the ProxyServer instance by assigning it to the self
@@ -202,6 +200,8 @@ auto PassField(Priority<1>, TypeList<>, ServerContext& server_context, const Fn&
202200
// Lookup Thread object specified by the client. The specified thread should
203201
// be a local Thread::Server object, but it needs to be looked up
204202
// asynchronously with getLocalServer().
203+
const auto& params = server_context.call_context.getParams();
204+
Context::Reader context_arg = Accessor::get(params);
205205
auto thread_client = context_arg.getThread();
206206
auto result = server.m_context.connection->m_threads.getLocalServer(thread_client)
207207
.then([&server, invoke = kj::mv(invoke), req](const kj::Maybe<Thread::Server&>& perhaps) mutable {

0 commit comments

Comments
 (0)