Commit 1dabe43f authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Workaround for std::make_shared bug in Xcode7, 7.1, and 7.2

std::make_shared in Xcode 7, 7.1, and 7.2 does not perform
value-initialization, and causes undefined behaviour if struct does
not have user defined default constructor.  This workaround explicitly
defines user defined default constructor, and initializes values.
parent 900aef10
......@@ -649,6 +649,15 @@ struct RouterConfig {
};
struct DownstreamConfig {
DownstreamConfig()
: timeout{},
addr_group_catch_all{0},
connections_per_host{0},
connections_per_frontend{0},
request_buffer_size{0},
response_buffer_size{0},
family{0} {}
struct {
ev_tstamp read;
ev_tstamp write;
......
......@@ -35,8 +35,6 @@
#include "shrpx_client_handler.h"
#include "shrpx_http2_session.h"
#include "shrpx_log_config.h"
#include "shrpx_connect_blocker.h"
#include "shrpx_live_check.h"
#include "shrpx_memcached_dispatcher.h"
#ifdef HAVE_MRUBY
#include "shrpx_mruby.h"
......@@ -186,8 +184,6 @@ void Worker::replace_downstream_config(
dst = std::make_shared<DownstreamAddrGroup>();
dst->pattern = src.pattern;
// TODO for some reason, clang-3.6 which comes with Ubuntu 15.10
// does not value initialize with std::make_shared.
auto shared_addr = std::make_shared<SharedDownstreamAddr>();
shared_addr->addrs.resize(src.addrs.size());
......
......@@ -46,6 +46,8 @@
#include "shrpx_downstream_connection_pool.h"
#include "memchunk.h"
#include "shrpx_ssl.h"
#include "shrpx_live_check.h"
#include "shrpx_connect_blocker.h"
using namespace nghttp2;
......@@ -53,7 +55,6 @@ namespace shrpx {
class Http2Session;
class ConnectBlocker;
class LiveCheck;
class MemcachedDispatcher;
struct UpstreamAddr;
class ConnectionHandler;
......@@ -126,6 +127,9 @@ struct WeightedPri {
};
struct SharedDownstreamAddr {
SharedDownstreamAddr()
: next{0}, http1_pri{}, http2_pri{}, affinity{AFFINITY_NONE} {}
std::vector<DownstreamAddr> addrs;
// Bunch of session affinity hash. Only used if affinity ==
// AFFINITY_IP.
......@@ -156,6 +160,8 @@ struct SharedDownstreamAddr {
};
struct DownstreamAddrGroup {
DownstreamAddrGroup() : retired{false} {};
ImmutableString pattern;
std::shared_ptr<SharedDownstreamAddr> shared_addr;
// true if this group is no longer used for new request. If this is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment