From ac97c122d47bc228941930e4197bc06e20836559 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 6 Jun 2016 00:16:25 +0900 Subject: [PATCH] nghttpx: Fix memory leak --- src/shrpx_worker.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/shrpx_worker.cc b/src/shrpx_worker.cc index 1a7cc90e..745de073 100644 --- a/src/shrpx_worker.cc +++ b/src/shrpx_worker.cc @@ -182,27 +182,29 @@ void Worker::replace_downstream_config( dst_addr.fall = src_addr.fall; dst_addr.rise = src_addr.rise; + auto shared_addr_ptr = shared_addr.get(); + dst_addr.connect_blocker = make_unique(randgen_, loop_, - [shared_addr, &dst_addr]() { + [shared_addr_ptr, &dst_addr]() { switch (dst_addr.proto) { case PROTO_HTTP1: - --shared_addr->http1_pri.weight; + --shared_addr_ptr->http1_pri.weight; break; case PROTO_HTTP2: - --shared_addr->http2_pri.weight; + --shared_addr_ptr->http2_pri.weight; break; default: assert(0); } }, - [shared_addr, &dst_addr]() { + [shared_addr_ptr, &dst_addr]() { switch (dst_addr.proto) { case PROTO_HTTP1: - ++shared_addr->http1_pri.weight; + ++shared_addr_ptr->http1_pri.weight; break; case PROTO_HTTP2: - ++shared_addr->http2_pri.weight; + ++shared_addr_ptr->http2_pri.weight; break; default: assert(0);