From 4b9ffa2c13222622e28c9eb35b703fc386c894bb Mon Sep 17 00:00:00 2001 From: Keivaun Waugh Date: Sun, 17 Sep 2023 18:20:20 -0700 Subject: [PATCH] Manage RevproxyController lifetime with shared_ptr Summary: Switch `getController` to return a `std::shared_ptr` to the controller instead of a raw pointer. Reviewed By: jalopezsilva Differential Revision: D48399432 fbshipit-source-id: 09cef6dec47596a991fba68ce5110558b5fd763c --- proxygen/lib/http/session/HTTPSessionAcceptor.cpp | 4 ++-- proxygen/lib/http/session/HTTPSessionAcceptor.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/proxygen/lib/http/session/HTTPSessionAcceptor.cpp b/proxygen/lib/http/session/HTTPSessionAcceptor.cpp index fd025cdafd..4dd1b9a288 100644 --- a/proxygen/lib/http/session/HTTPSessionAcceptor.cpp +++ b/proxygen/lib/http/session/HTTPSessionAcceptor.cpp @@ -30,7 +30,7 @@ HTTPSessionAcceptor::HTTPSessionAcceptor( std::shared_ptr codecFactory) : HTTPAcceptor(accConfig), codecFactory_(codecFactory), - simpleController_(this) { + simpleController_(std::make_shared(this)) { if (!codecFactory_) { codecFactory_ = std::make_shared(accConfig_); @@ -98,7 +98,7 @@ void HTTPSessionAcceptor::onNewConnection(folly::AsyncTransport::UniquePtr sock, std::move(sock), localAddress, *peerAddress, - controller, + controller.get(), std::move(codec), tinfo, sessionInfoCb); diff --git a/proxygen/lib/http/session/HTTPSessionAcceptor.h b/proxygen/lib/http/session/HTTPSessionAcceptor.h index b2c1415e43..9c5cadda54 100644 --- a/proxygen/lib/http/session/HTTPSessionAcceptor.h +++ b/proxygen/lib/http/session/HTTPSessionAcceptor.h @@ -100,8 +100,8 @@ class HTTPSessionAcceptor * override this function to provide their own more sophisticated * controller here. */ - virtual HTTPSessionController* getController() { - return &simpleController_; + virtual std::shared_ptr getController() { + return simpleController_; } HTTPSessionStats* downstreamSessionStats_{nullptr}; @@ -136,7 +136,7 @@ class HTTPSessionAcceptor std::shared_ptr codecFactory_{}; - SimpleController simpleController_; + std::shared_ptr simpleController_; HTTPSession::InfoCallback* sessionInfoCb_{nullptr};