From 1dabe43ff4c63c342f1341cba7ffa4ecb1a465d7 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 4 Sep 2016 23:30:24 +0900 Subject: [PATCH] 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. --- src/shrpx_config.h | 9 +++++++++ src/shrpx_worker.cc | 4 ---- src/shrpx_worker.h | 8 +++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/shrpx_config.h b/src/shrpx_config.h index 83570052..f0bc21a1 100644 --- a/src/shrpx_config.h +++ b/src/shrpx_config.h @@ -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; diff --git a/src/shrpx_worker.cc b/src/shrpx_worker.cc index 0d4a113a..4ef92264 100644 --- a/src/shrpx_worker.cc +++ b/src/shrpx_worker.cc @@ -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(); 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(); shared_addr->addrs.resize(src.addrs.size()); diff --git a/src/shrpx_worker.h b/src/shrpx_worker.h index 3503d0f7..4ca8fe22 100644 --- a/src/shrpx_worker.h +++ b/src/shrpx_worker.h @@ -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 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 shared_addr; // true if this group is no longer used for new request. If this is