nghttpx: Add BlockAllocator to SharedDownstreamAddr

This commit is contained in:
Tatsuhiro Tsujikawa 2016-10-02 16:18:35 +09:00
parent ede6104900
commit f5285d1f5a
2 changed files with 26 additions and 7 deletions

View File

@ -198,13 +198,16 @@ void Worker::replace_downstream_config(
auto &dst_addr = shared_addr->addrs[j];
dst_addr.addr = src_addr.addr;
dst_addr.host = src_addr.host;
dst_addr.hostport = src_addr.hostport;
dst_addr.host =
make_string_ref(shared_addr->balloc, StringRef{src_addr.host});
dst_addr.hostport =
make_string_ref(shared_addr->balloc, StringRef{src_addr.hostport});
dst_addr.port = src_addr.port;
dst_addr.host_unix = src_addr.host_unix;
dst_addr.proto = src_addr.proto;
dst_addr.tls = src_addr.tls;
dst_addr.sni = src_addr.sni;
dst_addr.sni =
make_string_ref(shared_addr->balloc, StringRef{src_addr.sni});
dst_addr.fall = src_addr.fall;
dst_addr.rise = src_addr.rise;

View File

@ -48,6 +48,7 @@
#include "shrpx_ssl.h"
#include "shrpx_live_check.h"
#include "shrpx_connect_blocker.h"
#include "allocator.h"
using namespace nghttp2;
@ -75,15 +76,15 @@ struct DownstreamAddr {
Address addr;
// backend address. If |host_unix| is true, this is UNIX domain
// socket path.
ImmutableString host;
ImmutableString hostport;
StringRef host;
StringRef hostport;
// backend port. 0 if |host_unix| is true.
uint16_t port;
// true if |host| contains UNIX domain socket path.
bool host_unix;
// sni field to send remote server if TLS is enabled.
ImmutableString sni;
StringRef sni;
std::unique_ptr<ConnectBlocker> connect_blocker;
std::unique_ptr<LiveCheck> live_check;
@ -128,8 +129,18 @@ struct WeightedPri {
struct SharedDownstreamAddr {
SharedDownstreamAddr()
: next{0}, http1_pri{}, http2_pri{}, affinity{AFFINITY_NONE} {}
: balloc(1024, 1024),
next{0},
http1_pri{},
http2_pri{},
affinity{AFFINITY_NONE} {}
SharedDownstreamAddr(const SharedDownstreamAddr &) = delete;
SharedDownstreamAddr(SharedDownstreamAddr &&) = delete;
SharedDownstreamAddr &operator=(const SharedDownstreamAddr &) = delete;
SharedDownstreamAddr &operator=(SharedDownstreamAddr &&) = delete;
BlockAllocator balloc;
std::vector<DownstreamAddr> addrs;
// Bunch of session affinity hash. Only used if affinity ==
// AFFINITY_IP.
@ -162,6 +173,11 @@ struct SharedDownstreamAddr {
struct DownstreamAddrGroup {
DownstreamAddrGroup() : retired{false} {};
DownstreamAddrGroup(const DownstreamAddrGroup &) = delete;
DownstreamAddrGroup(DownstreamAddrGroup &&) = delete;
DownstreamAddrGroup &operator=(const DownstreamAddrGroup &) = delete;
DownstreamAddrGroup &operator=(DownstreamAddrGroup &&) = delete;
ImmutableString pattern;
std::shared_ptr<SharedDownstreamAddr> shared_addr;
// true if this group is no longer used for new request. If this is