Commit 97ac3e79 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5134] Proposed patch to prevent static initialization fiasco.

On FreeBSD11 system the Control Agent unit tests fail because the
destructor of the LibraryManager is referencing ServerHooks. Both
are static and in this particular case the LibraryManager outlives
the other one.
parent 0852eacf
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -33,7 +33,8 @@ namespace hooks {
LibraryManager::LibraryManager(const std::string& name, int index,
const boost::shared_ptr<CalloutManager>& manager)
: dl_handle_(NULL), index_(index), manager_(manager),
library_name_(name)
library_name_(name),
server_hooks_(ServerHooks::getServerHooksPtr())
{
if (!manager) {
isc_throw(NoCalloutManager, "must specify a CalloutManager when "
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -8,7 +8,7 @@
#define LIBRARY_MANAGER_H
#include <exceptions/exceptions.h>
#include <hooks/server_hooks.h>
#include <boost/shared_ptr.hpp>
#include <string>
......@@ -219,6 +219,8 @@ private:
///< Callout manager for registration
std::string library_name_; ///< Name of the library
ServerHooksPtr server_hooks_; ///< Stores a pointer to ServerHooks.
};
} // namespace hooks
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -142,7 +142,12 @@ ServerHooks::getHookNames() const {
ServerHooks&
ServerHooks::getServerHooks() {
static ServerHooks hooks;
return (*getServerHooksPtr());
}
ServerHooksPtr
ServerHooks::getServerHooksPtr() {
static ServerHooksPtr hooks(new ServerHooks());
return (hooks);
}
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -10,6 +10,7 @@
#include <exceptions/exceptions.h>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <map>
#include <string>
......@@ -37,6 +38,8 @@ public:
isc::Exception(file, line, what) {}
};
class ServerHooks;
typedef boost::shared_ptr<ServerHooks> ServerHooksPtr;
/// @brief Server hook collection
///
......@@ -133,6 +136,11 @@ public:
/// @return Reference to the global ServerHooks object.
static ServerHooks& getServerHooks();
/// @brief Returns pointer to ServerHooks object.
///
/// @return Pointer to the global ServerHooks object.
static ServerHooksPtr getServerHooksPtr();
private:
/// @brief Constructor
///
......
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