Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++11 #105

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

C++11 #105

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ message(">>> EXECUTABLE_OUTPUT_PATH = ${EXECUTABLE_OUTPUT_PATH}")
# general
option(BUILD_SHARED_LIBS "Build Pion as shared library" ON)
option(BUILD_SPDY "Enable SPDY" OFF)
option(BUILD_UT "Enable Unit test" OFF)
option(BUILD_UT "Enable Unit test" ON)

# utils
option(BUILD_PIOND "Enable piond" ON)
Expand Down Expand Up @@ -78,11 +78,11 @@ include_directories(${PROJECT_WIDE_INCLUDE})
find_package(Threads REQUIRED)

# TODO: need to handle this with option
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_MULTITHREADED OFF)
#set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME OFF)

find_package(Boost COMPONENTS thread system filesystem regex unit_test_framework REQUIRED)
find_package(Boost COMPONENTS system filesystem unit_test_framework REQUIRED)
if (Boost_FOUND)
# disable autolinking feature
add_definitions(-DBOOST_ALL_NO_LIB)
Expand Down
64 changes: 32 additions & 32 deletions build/pion-boost.inc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ LIBS_SAVED="$LIBS"
LIBS="$LIBS_SAVED -l${BOOST_TRY_LINK}"
AC_MSG_CHECKING([for boost::${BOOST_TRY_LIB} library])
AC_TRY_LINK([#include <boost/system/error_code.hpp>],
[ boost::system::error_code error_code; std::string message(error_code.message()); return 0; ],
[ asio::error_code error_code; std::string message(error_code.message()); return 0; ],
[ AC_MSG_RESULT(ok)
BOOST_SYSTEM_LIB="-l${BOOST_TRY_LINK}"
],
Expand All @@ -72,22 +72,22 @@ AC_SUBST(BOOST_SYSTEM_LIB)


# Check for Boost Thread library
BOOST_TRY_LIB=thread
BOOST_TRY_LINK="boost_${BOOST_TRY_LIB}${BOOST_LIB_EXTENSION}"
LIBS_SAVED="$LIBS"
LIBS="$LIBS_SAVED -l${BOOST_TRY_LINK} ${BOOST_SYSTEM_LIB} ${BOOST_DATE_TIME_LIB}"
AC_MSG_CHECKING([for boost::${BOOST_TRY_LIB} library])
AC_TRY_LINK([#include <boost/thread/thread.hpp>
#include <boost/thread/condition.hpp>],
[ boost::thread current_thread; return 0; ],
[ AC_MSG_RESULT(ok)
BOOST_THREAD_LIB="-l${BOOST_TRY_LINK}"
],
[ AC_MSG_RESULT(not found)
AC_MSG_ERROR(Unable to link with the boost::${BOOST_TRY_LIB} library)
])
LIBS="$LIBS_SAVED"
AC_SUBST(BOOST_THREAD_LIB)
#BOOST_TRY_LIB=thread
#BOOST_TRY_LINK="boost_${BOOST_TRY_LIB}${BOOST_LIB_EXTENSION}"
#LIBS_SAVED="$LIBS"
#LIBS="$LIBS_SAVED -l${BOOST_TRY_LINK} ${BOOST_SYSTEM_LIB} ${BOOST_DATE_TIME_LIB}"
#AC_MSG_CHECKING([for boost::${BOOST_TRY_LIB} library])
#AC_TRY_LINK([#include <boost/thread/thread.hpp>
# #include <boost/thread/condition.hpp>],
# [ boost::thread current_thread; return 0; ],
# [ AC_MSG_RESULT(ok)
# BOOST_THREAD_LIB="-l${BOOST_TRY_LINK}"
# ],
# [ AC_MSG_RESULT(not found)
# AC_MSG_ERROR(Unable to link with the boost::${BOOST_TRY_LIB} library)
# ])
#LIBS="$LIBS_SAVED"
#AC_SUBST(BOOST_THREAD_LIB)


# Check for Boost Filesystem library
Expand All @@ -109,21 +109,21 @@ AC_SUBST(BOOST_FILESYSTEM_LIB)


# Check for Boost Regex library
BOOST_TRY_LIB=regex
BOOST_TRY_LINK="boost_${BOOST_TRY_LIB}${BOOST_LIB_EXTENSION}"
LIBS_SAVED="$LIBS"
LIBS="$LIBS_SAVED -l${BOOST_TRY_LINK}"
AC_MSG_CHECKING([for boost::${BOOST_TRY_LIB} library])
AC_TRY_LINK([#include <boost/regex.hpp>],
[ boost::regex exp(".*"); return 0; ],
[ AC_MSG_RESULT(ok)
BOOST_REGEX_LIB="-l${BOOST_TRY_LINK}"
],
[ AC_MSG_RESULT(not found)
AC_MSG_ERROR(Unable to link with the boost::${BOOST_TRY_LIB} library)
])
LIBS="$LIBS_SAVED"
AC_SUBST(BOOST_REGEX_LIB)
#BOOST_TRY_LIB=regex
#BOOST_TRY_LINK="boost_${BOOST_TRY_LIB}${BOOST_LIB_EXTENSION}"
#LIBS_SAVED="$LIBS"
#LIBS="$LIBS_SAVED -l${BOOST_TRY_LINK}"
#AC_MSG_CHECKING([for boost::${BOOST_TRY_LIB} library])
#AC_TRY_LINK([#include <boost/regex.hpp>],
# [ std::regex exp(".*"); return 0; ],
# [ AC_MSG_RESULT(ok)
# BOOST_REGEX_LIB="-l${BOOST_TRY_LINK}"
# ],
# [ AC_MSG_RESULT(not found)
# AC_MSG_ERROR(Unable to link with the boost::${BOOST_TRY_LIB} library)
# ])
#LIBS="$LIBS_SAVED"
#AC_SUBST(BOOST_REGEX_LIB)


# Check for Boost Unit Test Framework
Expand Down
19 changes: 9 additions & 10 deletions include/pion/admin_rights.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

#include <pion/config.hpp>
#include <pion/logger.hpp>
#include <boost/cstdint.hpp>
#include <boost/thread/mutex.hpp>
#include <mutex>


namespace pion { // begin namespace pion
Expand Down Expand Up @@ -54,31 +53,31 @@ class PION_API admin_rights {
* @param name descriptive name to lookup (user or group name, may be id)
* @param file system credentials file to look within
*
* @return boost::int32_t identifier found, or -1 if none found
* @return std::int32_t identifier found, or -1 if none found
*/
static long find_system_id(const std::string& name, const std::string& file);


/// adminisitrator or root user identifier
static const boost::int16_t ADMIN_USER_ID;
static const std::int16_t ADMIN_USER_ID;

/// mutex used to prevent multiple threads from corrupting user id
static boost::mutex m_mutex;
static std::mutex m_mutex;

/// primary logging interface used by this class
logger m_logger;
logger m_logger;

/// lock used to prevent multiple threads from corrupting user id
boost::unique_lock<boost::mutex> m_lock;
std::unique_lock<std::mutex> m_lock;

/// saved user identifier before upgrading to administrator
boost::int16_t m_user_id;
std::int16_t m_user_id;

/// true if the class currently holds administrative rights
bool m_has_rights;
bool m_has_rights;

/// if false, then no logging will be performed
bool m_use_log;
bool m_use_log;
};


Expand Down
Loading