From bc5bb67e1ea41c466c26ae9f7e816ba295e4e6fe Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 28 Mar 2017 07:59:28 -0600 Subject: [PATCH 1/2] Fix build on Linux Linux builds require linking against pthreads, which was not being done. Add pthreads to libraries to link against on Linux. --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 651c33df750..16257ea1222 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,8 @@ ENDIF(WIN32) FIND_PACKAGE(Boost 1.57 REQUIRED COMPONENTS ${BOOST_COMPONENTS}) +SET(PLATFORM_LIBRARIES) + if( APPLE ) # Apple Specific Options Here message( STATUS "Configuring ChainBase on OS X" ) @@ -38,6 +40,7 @@ else( APPLE ) if ( FULL_STATIC_BUILD ) set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") endif ( FULL_STATIC_BUILD ) + LIST( APPEND PLATFORM_LIBRARIES pthread ) endif( APPLE ) if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) @@ -63,7 +66,7 @@ endif() file(GLOB HEADERS "include/*.hpp") add_library( chainbase src/chainbase.cpp ${HEADERS} ) -target_link_libraries( chainbase ${Boost_LIBRARIES} ) +target_link_libraries( chainbase ${Boost_LIBRARIES} ${PLATFORM_LIBRARIES} ) target_include_directories( chainbase PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ${Boost_INCLUDE_DIR} ) add_subdirectory( test ) From 9421cfee75c8eb888c9408539f65ec9ed05b8ed0 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 30 Mar 2017 13:13:32 -0600 Subject: [PATCH 2/2] Add is_open method Add a method is_open() to check whether the database is currently open or not. --- include/chainbase/chainbase.hpp | 2 +- src/chainbase.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 287a124750a..3460fd64a1a 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -104,7 +104,6 @@ namespace chainbase { { typedef oid id_type; static const uint16_t type_id = TypeNumber; - }; /** this class is ment to be specified to enable lookup of index type by object type using @@ -654,6 +653,7 @@ namespace chainbase { }; void open( const bfs::path& dir, uint32_t write = read_only, uint64_t shared_file_size = 0 ); + bool is_open()const; void close(); void flush(); void wipe( const bfs::path& dir ); diff --git a/src/chainbase.cpp b/src/chainbase.cpp index cf389816c06..f6673ebbd9d 100644 --- a/src/chainbase.cpp +++ b/src/chainbase.cpp @@ -105,6 +105,11 @@ namespace chainbase { } } + bool database::is_open() const + { + return _segment && _meta && !_data_dir.empty(); + } + void database::flush() { if( _segment ) _segment->flush();