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.
This commit is contained in:
parent
900aef10da
commit
1dabe43ff4
|
@ -649,6 +649,15 @@ struct RouterConfig {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DownstreamConfig {
|
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 {
|
struct {
|
||||||
ev_tstamp read;
|
ev_tstamp read;
|
||||||
ev_tstamp write;
|
ev_tstamp write;
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
#include "shrpx_client_handler.h"
|
#include "shrpx_client_handler.h"
|
||||||
#include "shrpx_http2_session.h"
|
#include "shrpx_http2_session.h"
|
||||||
#include "shrpx_log_config.h"
|
#include "shrpx_log_config.h"
|
||||||
#include "shrpx_connect_blocker.h"
|
|
||||||
#include "shrpx_live_check.h"
|
|
||||||
#include "shrpx_memcached_dispatcher.h"
|
#include "shrpx_memcached_dispatcher.h"
|
||||||
#ifdef HAVE_MRUBY
|
#ifdef HAVE_MRUBY
|
||||||
#include "shrpx_mruby.h"
|
#include "shrpx_mruby.h"
|
||||||
|
@ -186,8 +184,6 @@ void Worker::replace_downstream_config(
|
||||||
dst = std::make_shared<DownstreamAddrGroup>();
|
dst = std::make_shared<DownstreamAddrGroup>();
|
||||||
dst->pattern = src.pattern;
|
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>();
|
auto shared_addr = std::make_shared<SharedDownstreamAddr>();
|
||||||
|
|
||||||
shared_addr->addrs.resize(src.addrs.size());
|
shared_addr->addrs.resize(src.addrs.size());
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
#include "shrpx_downstream_connection_pool.h"
|
#include "shrpx_downstream_connection_pool.h"
|
||||||
#include "memchunk.h"
|
#include "memchunk.h"
|
||||||
#include "shrpx_ssl.h"
|
#include "shrpx_ssl.h"
|
||||||
|
#include "shrpx_live_check.h"
|
||||||
|
#include "shrpx_connect_blocker.h"
|
||||||
|
|
||||||
using namespace nghttp2;
|
using namespace nghttp2;
|
||||||
|
|
||||||
|
@ -53,7 +55,6 @@ namespace shrpx {
|
||||||
|
|
||||||
class Http2Session;
|
class Http2Session;
|
||||||
class ConnectBlocker;
|
class ConnectBlocker;
|
||||||
class LiveCheck;
|
|
||||||
class MemcachedDispatcher;
|
class MemcachedDispatcher;
|
||||||
struct UpstreamAddr;
|
struct UpstreamAddr;
|
||||||
class ConnectionHandler;
|
class ConnectionHandler;
|
||||||
|
@ -126,6 +127,9 @@ struct WeightedPri {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SharedDownstreamAddr {
|
struct SharedDownstreamAddr {
|
||||||
|
SharedDownstreamAddr()
|
||||||
|
: next{0}, http1_pri{}, http2_pri{}, affinity{AFFINITY_NONE} {}
|
||||||
|
|
||||||
std::vector<DownstreamAddr> addrs;
|
std::vector<DownstreamAddr> addrs;
|
||||||
// Bunch of session affinity hash. Only used if affinity ==
|
// Bunch of session affinity hash. Only used if affinity ==
|
||||||
// AFFINITY_IP.
|
// AFFINITY_IP.
|
||||||
|
@ -156,6 +160,8 @@ struct SharedDownstreamAddr {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DownstreamAddrGroup {
|
struct DownstreamAddrGroup {
|
||||||
|
DownstreamAddrGroup() : retired{false} {};
|
||||||
|
|
||||||
ImmutableString pattern;
|
ImmutableString pattern;
|
||||||
std::shared_ptr<SharedDownstreamAddr> shared_addr;
|
std::shared_ptr<SharedDownstreamAddr> shared_addr;
|
||||||
// true if this group is no longer used for new request. If this is
|
// true if this group is no longer used for new request. If this is
|
||||||
|
|
Loading…
Reference in New Issue