Skip to content

Commit

Permalink
Take 2: 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: D49931458

fbshipit-source-id: a245ff8eb4a2fd24d69cdd851c09e354f251b7f5
  • Loading branch information
Keivaun Waugh authored and facebook-github-bot committed Oct 11, 2023
1 parent b96e0a3 commit ad9fd63
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 ad9fd63

Please sign in to comment.