Hi,
just came across this with our `mesos-this-capture` clang-tidy check:
> + // It is guaranteed that the continuation would run before the next
> + // request arrives. Also, it's fine to pass the `this` pointer to the
> + // continuation as this would get executed synchronously (if still
> pending)
> + // from `SocketManager::finalize()` due to it closing all active sockets
> + // during libprocess finalization.
> + parse(*request)
> + .onAny([this, socket, request](const Future<Message*>& future) {
Even though there is a comment hinting that capturing `this` here should be
safe, I am not sure this is a maintainable solution, e.g., still working if we
begin to manage the lifetime of `process_manager` instead of simple leaking a
global object. Above code would continue to compile in that case, but become
racy.
Is there some actor we could dispatch to to make this safe, or do we need a new
abstraction?
Cheers,
Benjamin