nghttpx: Use std::unique_ptr for ListenHandler::http2session_

This commit is contained in:
Tatsuhiro Tsujikawa 2014-06-27 00:39:53 +09:00
parent 68cd12ac29
commit 3312df42d2
2 changed files with 3 additions and 4 deletions

View File

@ -49,7 +49,6 @@ ListenHandler::ListenHandler(event_base *evbase, SSL_CTX *sv_ssl_ctx,
: evbase_(evbase), : evbase_(evbase),
sv_ssl_ctx_(sv_ssl_ctx), sv_ssl_ctx_(sv_ssl_ctx),
cl_ssl_ctx_(cl_ssl_ctx), cl_ssl_ctx_(cl_ssl_ctx),
http2session_(nullptr),
rate_limit_group_(bufferevent_rate_limit_group_new rate_limit_group_(bufferevent_rate_limit_group_new
(evbase, get_config()->worker_rate_limit_cfg)), (evbase, get_config()->worker_rate_limit_cfg)),
worker_stat_(util::make_unique<WorkerStat>()), worker_stat_(util::make_unique<WorkerStat>()),
@ -136,7 +135,7 @@ int ListenHandler::accept_connection(evutil_socket_t fd,
return -1; return -1;
} }
client->set_http2_session(http2session_); client->set_http2_session(http2session_.get());
return 0; return 0;
} }
size_t idx = worker_round_robin_cnt_ % num_worker_; size_t idx = worker_round_robin_cnt_ % num_worker_;
@ -164,7 +163,7 @@ event_base* ListenHandler::get_evbase() const
int ListenHandler::create_http2_session() int ListenHandler::create_http2_session()
{ {
int rv; int rv;
http2session_ = new Http2Session(evbase_, cl_ssl_ctx_); http2session_ = util::make_unique<Http2Session>(evbase_, cl_ssl_ctx_);
rv = http2session_->init_notification(); rv = http2session_->init_notification();
return rv; return rv;
} }

View File

@ -67,7 +67,7 @@ private:
SSL_CTX *cl_ssl_ctx_; SSL_CTX *cl_ssl_ctx_;
// Shared backend HTTP2 session. NULL if multi-threaded. In // Shared backend HTTP2 session. NULL if multi-threaded. In
// multi-threaded case, see shrpx_worker.cc. // multi-threaded case, see shrpx_worker.cc.
Http2Session *http2session_; std::unique_ptr<Http2Session> http2session_;
bufferevent_rate_limit_group *rate_limit_group_; bufferevent_rate_limit_group *rate_limit_group_;
std::unique_ptr<WorkerStat> worker_stat_; std::unique_ptr<WorkerStat> worker_stat_;
size_t num_worker_; size_t num_worker_;