diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 17 | ||||
-rw-r--r-- | contrib/epee/include/net/abstract_tcp_server2.h | 4 | ||||
-rw-r--r-- | contrib/epee/include/net/abstract_tcp_server2.inl | 4 | ||||
-rw-r--r-- | contrib/epee/include/serialization/keyvalue_serialization_overloads.h | 4 | ||||
-rw-r--r-- | src/crypto/oaes_lib.c | 1 | ||||
-rw-r--r-- | src/cryptonote_config.h | 2 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_format_utils.h | 2 | ||||
-rw-r--r-- | src/cryptonote_core/miner.cpp | 11 | ||||
-rw-r--r-- | src/cryptonote_core/miner.h | 2 | ||||
-rw-r--r-- | src/daemon/daemon_commands_handler.h | 5 | ||||
-rw-r--r-- | src/p2p/net_node.inl | 9 | ||||
-rw-r--r-- | src/p2p/p2p_protocol_defs.h | 4 | ||||
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 7 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 2 | ||||
-rw-r--r-- | tests/gtest/include/gtest/internal/gtest-port.h | 2 | ||||
-rw-r--r-- | tests/net_load_tests/net_load_tests.h | 14 | ||||
-rw-r--r-- | tests/performance_tests/performance_utils.h | 8 |
18 files changed, 69 insertions, 30 deletions
diff --git a/.gitignore b/.gitignore index 2a68f647b..554267b09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.DS_Store /build /tags
\ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b293cc78..69f0ef3eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,18 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(CMAKE_CONFIGURATION_TYPES "Debug;Release") enable_testing() +function(set_static_flags) + if (NOT APPLE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") + endif() +endfunction(set_static_flags) + include_directories(src contrib/epee/include external "${CMAKE_BINARY_DIR}/version") +if(APPLE) + include_directories(SYSTEM /usr/include/malloc) +endif() + set(STATIC ${MSVC} CACHE BOOL "Link libraries statically") if(MSVC) @@ -51,6 +61,9 @@ else() endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}") + if(APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0") + endif() if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)) set(DEBUG_FLAGS "-g3 -Og") else() @@ -65,7 +78,7 @@ else() set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}") if(STATIC) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") + set_static_flags() endif() endif() @@ -80,6 +93,8 @@ endif() include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) if(MINGW) set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock") +elseif(APPLE) + set(Boost_LIBRARIES "${Boost_LIBRARIES}") elseif(NOT MSVC) set(Boost_LIBRARIES "${Boost_LIBRARIES};rt") endif() diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h index 29bf59a57..b8e291c32 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.h +++ b/contrib/epee/include/net/abstract_tcp_server2.h @@ -153,7 +153,7 @@ namespace net_utils bool init_server(const std::string port, const std::string& address = "0.0.0.0"); /// Run the server's io_service loop. - bool run_server(size_t threads_count, bool wait = true); + bool run_server(size_t threads_count, bool wait = true, const boost::thread::attributes& attrs = boost::thread::attributes()); /// wait for service workers stop bool timed_wait_server_stop(uint64_t wait_mseconds); @@ -273,4 +273,4 @@ namespace net_utils #include "abstract_tcp_server2.inl" -#endif
\ No newline at end of file +#endif diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index 236bc1599..2a4b10e48 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -524,7 +524,7 @@ POP_WARNINGS } //--------------------------------------------------------------------------------- template<class t_protocol_handler> - bool boosted_tcp_server<t_protocol_handler>::run_server(size_t threads_count, bool wait) + bool boosted_tcp_server<t_protocol_handler>::run_server(size_t threads_count, bool wait, const boost::thread::attributes& attrs) { TRY_ENTRY(); m_threads_count = threads_count; @@ -538,7 +538,7 @@ POP_WARNINGS for (std::size_t i = 0; i < threads_count; ++i) { boost::shared_ptr<boost::thread> thread(new boost::thread( - boost::bind(&boosted_tcp_server<t_protocol_handler>::worker_thread, this))); + attrs, boost::bind(&boosted_tcp_server<t_protocol_handler>::worker_thread, this))); m_threads.push_back(thread); } CRITICAL_REGION_END(); diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h index 54535a404..33486d9ec 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h +++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h @@ -281,7 +281,7 @@ namespace epee } }; template<class t_storage> - struct base_serializable_types: public boost::mpl::vector<uint64_t, uint32_t, uint16_t, uint8_t, int64_t, int32_t, int16_t, int8_t, double, bool, std::string, typename t_storage::meta_entry>::type + struct base_serializable_types: public boost::mpl::vector<uint64_t, uint32_t, uint16_t, uint8_t, int64_t, int32_t, int16_t, int8_t, double, bool, std::string, typename t_storage::meta_entry>::type {}; //------------------------------------------------------------------------------------------------------------------- template<bool> struct selector; @@ -365,4 +365,4 @@ namespace epee return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname); } } -}
\ No newline at end of file +} diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c index d77c52f11..126f0a2f6 100644 --- a/src/crypto/oaes_lib.c +++ b/src/crypto/oaes_lib.c @@ -37,6 +37,7 @@ static const char _NR[] = { #include <malloc.h> #include <string.h> #include <stdlib.h> +#include <stdio.h> #ifdef WIN32 #include <process.h> diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index b7c0170e3..34d053aa8 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -79,5 +79,5 @@ #define P2P_NET_DATA_FILENAME "p2pstate.bin" #define MINER_CONFIG_FILE_NAME "miner_conf.json" - +#define THREAD_STACK_SIZE 5 * 1024 * 1024 diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index 554e466cc..5873d2943 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -25,7 +25,7 @@ namespace cryptonote typedef std::pair<uint64_t, crypto::public_key> output_entry; std::vector<output_entry> outputs; //index + key - uint64_t real_output; //index in outputs vector of real output_entry + size_t real_output; //index in outputs vector of real output_entry crypto::public_key real_out_tx_key; //incoming real tx public key size_t real_output_in_tx_index; //index in transaction outputs vector uint64_t amount; //money diff --git a/src/cryptonote_core/miner.cpp b/src/cryptonote_core/miner.cpp index 142c81f68..56b459d6e 100644 --- a/src/cryptonote_core/miner.cpp +++ b/src/cryptonote_core/miner.cpp @@ -193,7 +193,7 @@ namespace cryptonote return !m_stop; } //----------------------------------------------------------------------------------------------------- - bool miner::start(const account_public_address& adr, size_t threads_count) + bool miner::start(const account_public_address& adr, size_t threads_count, const boost::thread::attributes& attrs) { m_mine_address = adr; m_threads_total = static_cast<uint32_t>(threads_count); @@ -218,7 +218,9 @@ namespace cryptonote boost::interprocess::ipcdetail::atomic_write32(&m_thread_index, 0); for(size_t i = 0; i != threads_count; i++) - m_threads.push_back(boost::thread(boost::bind(&miner::worker_thread, this))); + { + m_threads.push_back(boost::thread(attrs, boost::bind(&miner::worker_thread, this))); + } LOG_PRINT_L0("Mining has started with " << threads_count << " threads, good luck!" ) return true; @@ -269,7 +271,10 @@ namespace cryptonote { if(m_do_mining) { - start(m_mine_address, m_threads_total); + boost::thread::attributes attrs; + attrs.set_stack_size(THREAD_STACK_SIZE); + + start(m_mine_address, m_threads_total, attrs); } } //----------------------------------------------------------------------------------------------------- diff --git a/src/cryptonote_core/miner.h b/src/cryptonote_core/miner.h index 03f09509e..da4578b06 100644 --- a/src/cryptonote_core/miner.h +++ b/src/cryptonote_core/miner.h @@ -35,7 +35,7 @@ namespace cryptonote static void init_options(boost::program_options::options_description& desc); bool set_block_template(const block& bl, const difficulty_type& diffic, uint64_t height); bool on_block_chain_update(); - bool start(const account_public_address& adr, size_t threads_count); + bool start(const account_public_address& adr, size_t threads_count, const boost::thread::attributes& attrs); uint64_t get_speed(); void send_stop_signal(); bool stop(); diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h index 7695508c9..dca524f77 100644 --- a/src/daemon/daemon_commands_handler.h +++ b/src/daemon/daemon_commands_handler.h @@ -291,7 +291,10 @@ private: threads_count = (ok && 0 < threads_count) ? threads_count : 1; } - m_srv.get_payload_object().get_core().get_miner().start(adr, threads_count); + boost::thread::attributes attrs; + attrs.set_stack_size(THREAD_STACK_SIZE); + + m_srv.get_payload_object().get_core().get_miner().start(adr, threads_count, attrs); return true; } //-------------------------------------------------------------------------------- diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index eeb3f6ffe..31d3e6597 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -278,9 +278,12 @@ namespace nodetool m_net_server.add_idle_handler(boost::bind(&node_server<t_payload_net_handler>::idle_worker, this), 1000); m_net_server.add_idle_handler(boost::bind(&t_payload_net_handler::on_idle, &m_payload_handler), 1000); + boost::thread::attributes attrs; + attrs.set_stack_size(THREAD_STACK_SIZE); + //go to loop LOG_PRINT("Run net_service loop( " << thrds_count << " threads)...", LOG_LEVEL_0); - if(!m_net_server.run_server(thrds_count)) + if(!m_net_server.run_server(thrds_count, true, attrs)) { LOG_ERROR("Failed to run net tcp server!"); } @@ -745,7 +748,9 @@ namespace nodetool template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::get_local_node_data(basic_node_data& node_data) { - time(&node_data.local_time); + time_t local_time; + time(&local_time); + node_data.local_time = local_time; node_data.peer_id = m_config.m_peer_id; if(!m_hide_my_port) node_data.my_port = m_external_port ? m_external_port : m_listenning_port; diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h index 9994dca4c..fdf784f49 100644 --- a/src/p2p/p2p_protocol_defs.h +++ b/src/p2p/p2p_protocol_defs.h @@ -86,7 +86,7 @@ namespace nodetool struct basic_node_data { uuid network_id; - time_t local_time; + uint64_t local_time; uint32_t my_port; peerid_type peer_id; @@ -153,7 +153,7 @@ namespace nodetool struct response { - time_t local_time; + uint64_t local_time; t_playload_type payload_data; std::list<peerlist_entry> local_peerlist; diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index bab373c86..4d78367b6 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -252,7 +252,10 @@ namespace cryptonote return true; } - if(!m_core.get_miner().start(adr, static_cast<size_t>(req.threads_count))) + boost::thread::attributes attrs; + attrs.set_stack_size(THREAD_STACK_SIZE); + + if(!m_core.get_miner().start(adr, static_cast<size_t>(req.threads_count), attrs)) { res.status = "Failed, mining not started"; return true; @@ -536,7 +539,7 @@ namespace cryptonote if (!have_block) { error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; - error_resp.message = "Internal error: can't get block by height. Height = " + req.height + '.'; + error_resp.message = "Internal error: can't get block by height. Height = " + std::to_string(req.height) + '.'; return false; } bool responce_filled = fill_block_header_responce(blk, false, req.height, block_hash, res.block_header); diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index a4cae0480..a9c171f6b 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -469,7 +469,7 @@ bool simple_wallet::refresh(const std::vector<std::string>& args) return true; message_writer() << "Starting refresh..."; - uint64_t fetched_blocks = 0; + size_t fetched_blocks = 0; bool ok = false; std::ostringstream ss; try diff --git a/tests/gtest/include/gtest/internal/gtest-port.h b/tests/gtest/include/gtest/internal/gtest-port.h index 157b47f86..fbf28cd4e 100644 --- a/tests/gtest/include/gtest/internal/gtest-port.h +++ b/tests/gtest/include/gtest/internal/gtest-port.h @@ -204,6 +204,8 @@ #define GTEST_NAME_ "Google Test" #define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/" +#define GTEST_HAS_TR1_TUPLE 0 + // Determines the version of gcc that is used to compile this. #ifdef __GNUC__ // 40302 means version 4.3.2. diff --git a/tests/net_load_tests/net_load_tests.h b/tests/net_load_tests/net_load_tests.h index 20da11bf3..3d9569835 100644 --- a/tests/net_load_tests/net_load_tests.h +++ b/tests/net_load_tests/net_load_tests.h @@ -212,8 +212,8 @@ namespace net_load_tests struct request { - size_t open_request_target; - size_t max_opened_conn_count; + uint64_t open_request_target; + uint64_t max_opened_conn_count; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(open_request_target) @@ -240,9 +240,9 @@ namespace net_load_tests struct response { - size_t opened_connections_count; - size_t new_connection_counter; - size_t close_connection_counter; + uint64_t opened_connections_count; + uint64_t new_connection_counter; + uint64_t close_connection_counter; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(opened_connections_count) @@ -295,7 +295,7 @@ namespace net_load_tests struct request { - size_t request_size; + uint64_t request_size; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(request_size) @@ -310,7 +310,7 @@ namespace net_load_tests struct request { std::string data; - size_t response_size; + uint64_t response_size; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(data) diff --git a/tests/performance_tests/performance_utils.h b/tests/performance_tests/performance_utils.h index b2ac4076f..fe1e1c7cd 100644 --- a/tests/performance_tests/performance_utils.h +++ b/tests/performance_tests/performance_utils.h @@ -14,7 +14,9 @@ void set_process_affinity(int core) { -#if defined(BOOST_WINDOWS) +#if defined(__APPLE__) + return; +#elif defined(BOOST_WINDOWS) DWORD_PTR mask = 1; for (int i = 0; i < core; ++i) { @@ -34,7 +36,9 @@ void set_process_affinity(int core) void set_thread_high_priority() { -#if defined(BOOST_WINDOWS) +#if defined(__APPLE__) + return; +#elif defined(BOOST_WINDOWS) ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); #elif defined(BOOST_HAS_PTHREADS) pthread_attr_t attr; |