diff --git a/lib/msf/core/rpc/v10/service.rb b/lib/msf/core/rpc/v10/service.rb index 90f8c3b3e6d8..81dfbbb99064 100644 --- a/lib/msf/core/rpc/v10/service.rb +++ b/lib/msf/core/rpc/v10/service.rb @@ -140,11 +140,16 @@ def process(req) end end - ::Timeout.timeout(self.dispatcher_timeout) { self.handlers[group].send(mname, *msg) } + ::Timeout.timeout(self.dispatcher_timeout) do + Thread.current[:rpc_token] = token + self.handlers[group].send(mname, *msg) + end rescue ::Exception => e elog('RPC Exception', error: e) process_exception(e) + ensure + Thread.current[:rpc_token] = nil end end