Commit f0dd8824 authored by Stephen Morris's avatar Stephen Morris

Merge branch 'master' into trac499

parents af01e66f bb708b65
......@@ -66,6 +66,11 @@ if test $enable_shared = no; then
AC_MSG_ERROR([BIND 10 requires shared libraries to be built])
fi
AC_ARG_ENABLE(boost-threads,
AC_HELP_STRING([--enable-boost-threads],
[use boost threads. Currently this only means using its locks instead of dummy locks, in the cache and NSAS]),
use_boost_threads=$enableval, use_boost_threads=no)
# allow configuring without setproctitle.
AC_ARG_ENABLE(setproctitle-check,
AC_HELP_STRING([--disable-setproctitle-check],
......@@ -443,62 +448,69 @@ AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/foreach.hpp boost/interprocess/sync
CPPFLAGS="$CPPFLAGS_SAVES"
AC_SUBST(BOOST_INCLUDES)
# Using boost::mutex can result in requiring libboost_thread with older
# versions of Boost. We'd like to avoid relying on a compiled Boost library
# whenever possible, so we need to check for it step by step.
#
# NOTE: another fix of this problem is to simply require newer versions of
# boost. If we choose that solution we should simplify the following tricky
# checks accordingly and all Makefile.am's that refer to NEED_LIBBOOST_THREAD.
AC_MSG_CHECKING(for boost::mutex)
CPPFLAGS_SAVES="$CPPFLAGS"
LIBS_SAVES="$LIBS"
CPPFLAGS="$BOOST_INCLUDES $CPPFLAGS $MULTITHREADING_FLAG"
need_libboost_thread=0
need_sunpro_workaround=0
AC_TRY_LINK([
#include <boost/thread.hpp>
],[
boost::mutex m;
],
[ AC_MSG_RESULT(yes (without libboost_thread)) ],
# there is one specific problem with SunStudio 5.10
# where including boost/thread causes a compilation failure
# There is a workaround in boost but it checks the version not being 5.10
# This will probably be fixed in the future, in which case this
# is only a temporary workaround
[ AC_TRY_LINK([
#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
#undef __SUNPRO_CC
#define __SUNPRO_CC 0x5090
#endif
#include <boost/thread.hpp>
],[
boost::mutex m;
],
[ AC_MSG_RESULT(yes (with SUNOS workaround))
need_sunpro_workaround=1 ],
[ LIBS=" $LIBS -lboost_thread"
AC_TRY_LINK([
#include <boost/thread.hpp>
],[
boost::mutex m;
],
[ AC_MSG_RESULT(yes (with libboost_thread))
need_libboost_thread=1 ],
[ AC_MSG_RESULT(no)
AC_MSG_ERROR([boost::mutex cannot be linked in this build environment.
Perhaps you are using an older version of Boost that requires libboost_thread for the mutex support, which does not appear to be available.
You may want to check the availability of the library or to upgrade Boost.])
])])])
CPPFLAGS="$CPPFLAGS_SAVES"
LIBS="$LIBS_SAVES"
AM_CONDITIONAL(NEED_LIBBOOST_THREAD, test $need_libboost_thread = 1)
if test $need_sunpro_workaround = 1; then
AC_DEFINE([NEED_SUNPRO_WORKAROUND], [], [Need boost sunstudio workaround])
if test "${use_boost_threads}" = "yes" ; then
AC_DEFINE([USE_BOOST_THREADS], [], [Use boost threads])
# Using boost::mutex can result in requiring libboost_thread with older
# versions of Boost. We'd like to avoid relying on a compiled Boost library
# whenever possible, so we need to check for it step by step.
#
# NOTE: another fix of this problem is to simply require newer versions of
# boost. If we choose that solution we should simplify the following tricky
# checks accordingly and all Makefile.am's that refer to NEED_LIBBOOST_THREAD.
AC_MSG_CHECKING(for boost::mutex)
CPPFLAGS_SAVES="$CPPFLAGS"
LIBS_SAVES="$LIBS"
CPPFLAGS="$BOOST_INCLUDES $CPPFLAGS $MULTITHREADING_FLAG"
need_libboost_thread=0
need_sunpro_workaround=0
AC_TRY_LINK([
#include <boost/thread.hpp>
],[
boost::mutex m;
],
[ AC_MSG_RESULT(yes (without libboost_thread)) ],
# there is one specific problem with SunStudio 5.10
# where including boost/thread causes a compilation failure
# There is a workaround in boost but it checks the version not being 5.10
# This will probably be fixed in the future, in which case this
# is only a temporary workaround
[ AC_TRY_LINK([
#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
#undef __SUNPRO_CC
#define __SUNPRO_CC 0x5090
#endif
#include <boost/thread.hpp>
],[
boost::mutex m;
],
[ AC_MSG_RESULT(yes (with SUNOS workaround))
need_sunpro_workaround=1 ],
[ LIBS=" $LIBS -lboost_thread"
AC_TRY_LINK([
#include <boost/thread.hpp>
],[
boost::mutex m;
],
[ AC_MSG_RESULT(yes (with libboost_thread))
need_libboost_thread=1 ],
[ AC_MSG_RESULT(no)
AC_MSG_ERROR([boost::mutex cannot be linked in this build environment.
Perhaps you are using an older version of Boost that requires libboost_thread for the mutex support, which does not appear to be available.
You may want to check the availability of the library or to upgrade Boost.])
])])])
CPPFLAGS="$CPPFLAGS_SAVES"
LIBS="$LIBS_SAVES"
AM_CONDITIONAL(NEED_LIBBOOST_THREAD, test $need_libboost_thread = 1)
if test $need_sunpro_workaround = 1; then
AC_DEFINE([NEED_SUNPRO_WORKAROUND], [], [Need boost sunstudio workaround])
fi
else
AM_CONDITIONAL(NEED_LIBBOOST_THREAD, test "${use_boost_threads}" = "yes")
fi
#
# Check availability of gtest, which will be used for unit tests.
#
......
......@@ -201,7 +201,7 @@ MockZone::find(const Name& name, const RRType& type,
// If not found but we have a target, fill it with all RRsets here
if (!found_domain->second.empty() && target != NULL) {
for (found_rrset = found_domain->second.begin();
found_rrset != found_domain->second.end(); found_rrset++) {
found_rrset != found_domain->second.end(); ++found_rrset) {
// Insert RRs under the domain name into target
target->addRRset(
boost::const_pointer_cast<RRset>(found_rrset->second));
......
......@@ -1157,7 +1157,7 @@ MetaDataSrc::addDataSrc(ConstDataSrcPtr data_src) {
void
MetaDataSrc::removeDataSrc(ConstDataSrcPtr data_src) {
std::vector<ConstDataSrcPtr>::iterator it, itr;
for (it = data_sources.begin(); it != data_sources.end(); it++) {
for (it = data_sources.begin(); it != data_sources.end(); ++it) {
if (*it == data_src) {
itr = it;
}
......
......@@ -515,7 +515,7 @@ struct MemoryZone::MemoryZoneImpl {
if (target != NULL && !node->getData()->empty()) {
// Empty domain will be handled as NXRRSET by normal processing
for (found = node->getData()->begin();
found != node->getData()->end(); found++)
found != node->getData()->end(); ++found)
{
target->addRRset(
boost::const_pointer_cast<RRset>(prepareRRset(name,
......
......@@ -25,6 +25,7 @@ libnsas_la_SOURCES += asiolink.h
libnsas_la_SOURCES += hash.cc hash.h
libnsas_la_SOURCES += hash_deleter.h
libnsas_la_SOURCES += hash_key.cc hash_key.h
libnsas_la_SOURCES += locks.h
libnsas_la_SOURCES += hash_table.h
libnsas_la_SOURCES += lru_list.h
libnsas_la_SOURCES += nameserver_address_store.cc nameserver_address_store.h
......
......@@ -15,25 +15,11 @@
#ifndef __HASH_TABLE_H
#define __HASH_TABLE_H
// Workaround for a problem with boost and sunstudio 5.10
// There is a version check in there that appears wrong,
// which makes including boost/thread.hpp fail
// This will probably be fixed in a future version of boost,
// in which case this part can be removed then
#ifdef NEED_SUNPRO_WORKAROUND
#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
#undef __SUNPRO_CC
#define __SUNPRO_CC 0x5090
#endif
#endif // NEED_SUNPRO_WORKAROUND
#include <list>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/interprocess/sync/sharable_lock.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
#include <list>
#include "locks.h"
#include "hash.h"
#include "hash_key.h"
......@@ -61,7 +47,7 @@ struct HashTableSlot {
typedef typename std::list<boost::shared_ptr<T> >::iterator iterator;
///< Iterator over elements with same hash
typedef boost::interprocess::interprocess_upgradable_mutex mutex_type;
typedef isc::locks::upgradable_mutex mutex_type;
///< Mutex protecting this slot
//@}
......@@ -128,11 +114,11 @@ public:
///
//@{
typedef typename
boost::interprocess::sharable_lock<typename HashTableSlot<T>::mutex_type>
isc::locks::sharable_lock<typename HashTableSlot<T>::mutex_type>
sharable_lock; ///< Type for a scope-limited read-lock
typedef typename
boost::interprocess::scoped_lock<typename HashTableSlot<T>::mutex_type>
isc::locks::scoped_lock<typename HashTableSlot<T>::mutex_type>
scoped_lock; ///< Type for a scope-limited write-lock
//@}
......
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
/// This file (right now) provides dummy locks
/// It also contains code to use boost/threads locks:
///
/// if USE_BOOST_THREADS is defined, we typedef the relevant classes
/// and derive from the relevant templates so our dummy locks are
/// replaced by the boost locks (--enable-boost-threads)
///
/// If USE_BOOST_THREADS is NOT defined, all locks are dummy classes
/// that don't actually do anything. At this moment, only the very
/// minimal set of methods that we actually use is defined.
///
/// Note that we need to include <config.h> in our .cc files for that
/// to be set. we might want to enfore this at compile time with a check
/// (TODO)
/// Note that this also contains a workaround for Sunstudio; which
/// probably won't completely work right now (that is, if the TODO
/// above is completed), since that would also require some changes
/// in most (at first glance unrelated) Makefiles
/// (TODO2)
#ifndef __LOCKS_
#define __LOCKS_
#ifndef USE_BOOST_THREADS
namespace isc {
namespace locks {
class mutex {
};
class recursive_mutex {
};
class upgradable_mutex {
};
template <typename T>
class sharable_lock {
public:
sharable_lock(T) { }
};
template <typename T>
class scoped_lock {
public:
scoped_lock(T) { }
void lock() {}
void unlock() {}
};
}
}
#else // USE_BOOST_THREADS
// Workaround for a problem with boost and sunstudio 5.10
// There is a version check in there that appears wrong,
// which makes including boost/thread.hpp fail
// This will probably be fixed in a future version of boost,
// in which case this part can be removed then
#ifdef NEED_SUNPRO_WORKAROUND
#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
#undef __SUNPRO_CC
#define __SUNPRO_CC 0x5090
#endif
#endif // NEED_SUNPRO_WORKAROUND
#include <boost/thread.hpp>
#include <boost/interprocess/sync/sharable_lock.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
namespace isc {
namespace locks {
typedef boost::mutex mutex;
typedef boost::interprocess::interprocess_upgradable_mutex upgradable_mutex;
typedef boost::interprocess::interprocess_recursive_mutex recursive_mutex;
template <typename T>
struct sharable_lock : public boost::interprocess::sharable_lock<T> {
public:
sharable_lock(T& mtype) : boost::interprocess::sharable_lock<T>(mtype) {}
};
template <class T>
struct scoped_lock : public boost::interprocess::scoped_lock<T> {
public:
scoped_lock(T& mtype) : boost::interprocess::scoped_lock<T>(mtype) { }
};
}
}
#endif // USE_BOOST_THREADS
#endif // __LOCKS_
......@@ -18,22 +18,10 @@
#include <list>
#include <string>
// Workaround for a problem with boost and sunstudio 5.10
// There is a version check in there that appears wrong,
// which makes including boost/thread.hpp fail
// This will probably be fixed in a future version of boost,
// in which case this part can be removed then
#ifdef NEED_SUNPRO_WORKAROUND
#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
#undef __SUNPRO_CC
#define __SUNPRO_CC 0x5090
#endif
#endif // NEED_SUNPRO_WORKAROUND
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include "locks.h"
namespace isc {
namespace nsas {
......@@ -151,7 +139,7 @@ public:
}
private:
boost::mutex mutex_; ///< List protection
isc::locks::mutex mutex_; ///< List protection
std::list<boost::shared_ptr<T> > lru_; ///< The LRU list itself
uint32_t max_size_; ///< Max size of the list
uint32_t count_; ///< Count of elements
......@@ -163,7 +151,7 @@ template <typename T>
void LruList<T>::add(boost::shared_ptr<T>& element) {
// Protect list against concurrent access
boost::interprocess::scoped_lock<boost::mutex> lock(mutex_);
isc::locks::scoped_lock<isc::locks::mutex> lock(mutex_);
// Add the entry and set its pointer field to point into the list.
// insert() is used to get the pointer.
......@@ -212,7 +200,7 @@ void LruList<T>::remove(boost::shared_ptr<T>& element) {
if (element->iteratorValid()) {
// Is valid, so protect list against concurrent access
boost::interprocess::scoped_lock<boost::mutex> lock(mutex_);
isc::locks::scoped_lock<isc::locks::mutex> lock(mutex_);
lru_.erase(element->getLruIterator()); // Remove element from list
element->invalidateIterator(); // Invalidate pointer
......@@ -228,7 +216,7 @@ void LruList<T>::touch(boost::shared_ptr<T>& element) {
if (element->iteratorValid()) {
// Protect list against concurrent access
boost::interprocess::scoped_lock<boost::mutex> lock(mutex_);
isc::locks::scoped_lock<isc::locks::mutex> lock(mutex_);
// Move the element to the end of the list.
lru_.splice(lru_.end(), lru_, element->getLruIterator());
......
......@@ -14,20 +14,6 @@
#include <config.h>
// Workaround for a problem with boost and sunstudio 5.10
// There is a version check in there that appears wrong,
// which makes including boost/thread.hpp fail
// This will probably be fixed in a future version of boost,
// in which case this part can be removed then
#ifdef NEED_SUNPRO_WORKAROUND
#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
#undef __SUNPRO_CC
#define __SUNPRO_CC 0x5090
#endif
#endif // NEED_SUNPRO_WORKAROUND
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
......@@ -35,6 +21,7 @@
#include <config.h>
#include <dns/rdataclass.h>
#include "locks.h"
#include "hash_table.h"
#include "lru_list.h"
#include "hash_deleter.h"
......
......@@ -50,7 +50,7 @@ namespace nsas {
namespace {
// Just shorter type alias
typedef boost::recursive_mutex::scoped_lock Lock;
typedef isc::locks::scoped_lock<isc::locks::recursive_mutex> Lock;
}
......
......@@ -15,21 +15,8 @@
#ifndef __NAMESERVER_ENTRY_H
#define __NAMESERVER_ENTRY_H
// Workaround for a problem with boost and sunstudio 5.10
// There is a version check in there that appears wrong,
// which makes including boost/thread.hpp fail
// This will probably be fixed in a future version of boost,
// in which case this part can be removed then
#ifdef NEED_SUNPRO_WORKAROUND
#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
#undef __SUNPRO_CC
#define __SUNPRO_CC 0x5090
#endif
#endif // NEED_SUNPRO_WORKAROUND
#include <string>
#include <vector>
#include <boost/thread.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <exceptions/exceptions.h>
......@@ -252,7 +239,7 @@ public:
//@}
private:
mutable boost::recursive_mutex mutex_; ///< Mutex protecting this object
mutable isc::locks::recursive_mutex mutex_;///< Mutex protecting this object
std::string name_; ///< Canonical name of the nameserver
isc::dns::RRClass classCode_; ///< Class of the nameserver
/**
......
......@@ -22,6 +22,7 @@
#include <string>
#include <vector>
#include <map>
#include <config.h>
......
......@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <map>
#include <config.h>
#include "zone_entry.h"
......@@ -49,7 +51,7 @@ ZoneEntry::ZoneEntry(
namespace {
// Shorter aliases for frequently used types
typedef boost::recursive_mutex::scoped_lock Lock; // Local lock, nameservers not locked
typedef isc::locks::scoped_lock<isc::locks::recursive_mutex> Lock; // Local lock, nameservers not locked
typedef boost::shared_ptr<AddressRequestCallback> CallbackPtr;
/*
......
......@@ -15,22 +15,9 @@
#ifndef __ZONE_ENTRY_H
#define __ZONE_ENTRY_H
// Workaround for a problem with boost and sunstudio 5.10
// There is a version check in there that appears wrong,
// which makes including boost/thread.hpp fail
// This will probably be fixed in a future version of boost,
// in which case this part can be removed then
#ifdef NEED_SUNPRO_WORKAROUND
#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
#undef __SUNPRO_CC
#define __SUNPRO_CC 0x5090
#endif
#endif // NEED_SUNPRO_WORKAROUND
#include <string>
#include <vector>
#include <set>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
......@@ -38,6 +25,7 @@
#include <resolve/resolver_interface.h>
#include "locks.h"
#include "hash_key.h"
#include "nsas_entry.h"
#include "asiolink.h"
......@@ -131,7 +119,7 @@ protected:
time_t expiry_; ///< Expiry time of this entry, 0 means not set
//}@
private:
mutable boost::recursive_mutex mutex_; ///< Mutex protecting this zone entry
mutable isc::locks::recursive_mutex mutex_;///< Mutex protecting this zone entry
std::string name_; ///< Canonical zone name
isc::dns::RRClass class_code_; ///< Class code
/**
......
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