Skip to content

Commit

Permalink
Manage RevproxyController lifetime with shared_ptr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Keivaun Waugh authored and facebook-github-bot committed Sep 18, 2023
1 parent 8e3f986 commit 4b9ffa2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions proxygen/lib/http/session/HTTPSessionAcceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ HTTPSessionAcceptor::HTTPSessionAcceptor(
std::shared_ptr<HTTPCodecFactory> codecFactory)
: HTTPAcceptor(accConfig),
codecFactory_(codecFactory),
simpleController_(this) {
simpleController_(std::make_shared<SimpleController>(this)) {
if (!codecFactory_) {
codecFactory_ =
std::make_shared<HTTPDefaultSessionCodecFactory>(accConfig_);
Expand Down Expand Up @@ -98,7 +98,7 @@ void HTTPSessionAcceptor::onNewConnection(folly::AsyncTransport::UniquePtr sock,
std::move(sock),
localAddress,
*peerAddress,
controller,
controller.get(),
std::move(codec),
tinfo,
sessionInfoCb);
Expand Down
6 changes: 3 additions & 3 deletions proxygen/lib/http/session/HTTPSessionAcceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTTPSessionController> getController() {
return simpleController_;
}

HTTPSessionStats* downstreamSessionStats_{nullptr};
Expand Down Expand Up @@ -136,7 +136,7 @@ class HTTPSessionAcceptor

std::shared_ptr<HTTPCodecFactory> codecFactory_{};

SimpleController simpleController_;
std::shared_ptr<SimpleController> simpleController_;

HTTPSession::InfoCallback* sessionInfoCb_{nullptr};

Expand Down

0 comments on commit 4b9ffa2

Please sign in to comment.