forked from lthn/blockchain
Coverity (#28)
* stratum_server: resolve CID 210144 (UNINIT_CTOR) * stratum_server: resolve CID 210042/210085/210104 (UNCAUGHT_EXCEPT) The potential to throw exists within the logger, remove_blockchain_update_listener, and any paths involving the logger (including CATCH_ENTRY_*). * epee: misc_log_ex: create CATCH_ENTRY_NO_RETURN macro A temporary substition for what I hope will eventually be a full-fledged exception-dispatcher (class-based, not macro). * stratum_server: resolve CID 210080/210084/210089 (UNCAUGHT_EXCEPT) The potential to throw exists within the logger, remove_protocol_handler, and any paths involving the logger (including CATCH_ENTRY_*). * epee: levin_protocol_handler_async: resolve CID 210140/210182/210165 (UNCAUGHT_EXCEPT) The potential to throw exists within guarded_critical_region_t, and any paths involving the logger (including CATCH_ENTRY_*). * epee: levin_protocol_handler_async: resolve CID 210110/210119/210155 (UNCAUGHT_EXCEPT) The potential to throw exists within the logger, del_connection, and any paths involving the logger (including CATCH_ENTRY_*). * epee: misc_log_ex: move macros to *top* of file so they can be used *within* this file. * daemon: resolve CID 210069/210092/210166 (UNCAUGHT_EXCEPT) The potential to throw exists within log_space, and any paths involving the logger (including CATCH_ENTRY_*). * daemon: return cstdlib proper types in main * simplewallet: resolve 6 different CIDs (UNCAUGHT_EXCEPT) CID: 210082 CID: 210086 CID: 210096 CID: 210147 CID: 210149 CID: 210150 The potential to throw exists throughout various paths in main. * simplewallet: return cstdlib proper types in main * simplewallet: resolve CID 210128/210160 (UNCAUGHT_EXCEPT) The potential to throw exists within various paths, and any paths involving the logger (including CATCH_ENTRY_*). * conn_tool: resolve 5 different CIDs (UNCAUGHT_EXCEPT) CID: 210038 CID: 210047 CID: 210108 CID: 210122 CID: 210157 The potential to throw exists throughout various paths in main. * conn_tool: return cstdlib proper types in main * miniupnp_helper: resolve CID 210050 (UNCAUGHT_EXCEPT) The potential to throw exists within deinit, including any paths involving the logger (including CATCH_ENTRY_*). * epee: profile_tools: resolve CID 210055 (UNCAUGHT_EXCEPT) The potential to throw exists within boost microsec_clock::localtime(), and any paths involving the logger (including CATCH_ENTRY_*). * db_backend_lmdb: resolve CID 210056/210133 (UNCAUGHT_EXCEPT) The potential to throw exists within close(), including any paths involving the logger (including CATCH_ENTRY_*). * epee: misc_log_ex: resolve CID 210060/210124 (UNCAUGHT_EXCEPT) The potential to throw exists within several paths, including any paths involving the logger (including CATCH_ENTRY_*). * epee: misc_language: resolve 4 CIDs (UNCAUGHT_EXCEPT) CID: 210064 CID: 210093 CID: 210136 CID: 210139 The potential to throw exists within m_func(), including any paths involving the logger (including CATCH_ENTRY_*). * db_abstract_accessor: resolve 4 CIDs (UNCAUGHT_EXCEPT) CID: 210072 CID: 210094 CID: 210116 CID: 210141 The potential to throw exists within m_cache.clear(), including any paths involving the logger (including CATCH_ENTRY_*). * epee: net_helper: resolve CID 210100 (UNCAUGHT_EXCEPT) The potential to throw exists within shutdown(), including any paths involving the logger (including CATCH_ENTRY_*). * epee: syncobj: resolve CID 210123 (UNCAUGHT_EXCEPT) The potential to throw exists within unlock(), including any paths involving the logger (including CATCH_ENTRY_*). * epee: profile_tools: resolve CID 210145/210154 (UNCAUGHT_EXCEPT) The potential to throw exists within various paths, including any paths involving the logger (including CATCH_ENTRY_*). * epee: http_base: resolve CID 210176 (UNINIT_CTOR) * p2p: net_node: resolve CID 210173 (UNINIT_CTOR) * epee: net_helper: resolve CID 210138 (UNINIT_CTOR) * p2p: net_peerlist: resolve CID 210137 (UNINIT_CTOR) * currency_basic: resolve CID 210117 (UNINIT_CTOR) * epee: abstract_tcp_server2: resolve 3 CIDs (UNINIT_CTOR) CID: 210040 CID: 210090 CID: 210105 * simplewallet: resolve CID 210103 (UNINIT_CTOR) * epee: levin_protocol_handler_async: resolve CID 210091 (UNINIT_CTOR) * json_archive: resolve CID 210087 (UNINIT_CTOR) * epee: levin_protocol_handler_async: resolve CID 210073 (UNINIT_CTOR) * miniupnp_helper: resolve CID 210037 (UNINIT_CTOR) * crypto: ge_frombytes_vartime: resolve CID 210142 (CHECKED_RETURN) * wallet2: resolve CID 210041 (CHECKED_RETURN) * epee: misc_log_ex: resolve CID 210127 (DEADCODE) * epee: levin_protocol_handler_sync: resolve 3 CIDs (PASS_BY_VALUE) CID: 210167 CID: 210170 CID: 210180 * p2p: net_node: resolve CID 210065 (PASS_BY_VALUE) * epee: levin_abstract_invoke2: resolve CID 210049 (PASS_BY_VALUE) * epee: abstract_tcp_server2: resolve CID 210045 (PASS_BY_VALUE) * epee: misc_log_ex: add NESTED_*_ENTRY macros * simplewallet: use NESTED_*_ENTRY in message_writer dtor * stratum_protocol_handler_config: use NESTED_*_ENTRY in dtor * stratum_protocol_handler: use NESTED_*_ENTRY in dtor * lmdb_db_backend: use NESTED_*_ENTRY in dtor * epee: abstract_tcp_server2: resolve 4 CIDs (UNCAUGHT_EXCEPT) CID: 210088 CID: 210106 CID: 210164 CID: 210179 The potential to throw exists within various paths, including any paths involving the logger (including CATCH_ENTRY_*). * db_abstract_accessor: use NESTED_*_ENTRY in dtor * miniupnp_helper: use NESTED_*_ENTRY in dtor * epee: misc_log_ex: use NESTED_*_ENTRY in log_frame dtor * epee: levin_protocol_handler_async: use NESTED_*_ENTRY in dtors * epee: net_helper: use NESTED_*_ENTRY in dtor * epee: profile_tools: use NESTED_*_ENTRY in dtors * epee: misc_language: use NESTED_*_ENTRY in dtor * epee: syncobj: use NESTED_*_ENTRY in dtor * zano: license contact w/ zano.org email instead of sekreta.org email
This commit is contained in:
parent
55d169c926
commit
950f9c16f6
24 changed files with 430 additions and 307 deletions
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2019, anonimal, <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -313,7 +314,11 @@ namespace misc_utils
|
|||
{}
|
||||
~call_befor_die()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
m_func();
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2019, anonimal <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -118,6 +119,187 @@ DISABLE_VS_WARNINGS(4100)
|
|||
|
||||
#define LOCATION_SS "[" << LOCAL_FUNCTION_DEF__ << ("] @ " __FILE__ ":" STR(__LINE__))
|
||||
|
||||
#if !defined(DISABLE_RELEASE_LOGGING)
|
||||
#define ENABLE_LOGGING_INTERNAL
|
||||
#endif
|
||||
|
||||
#define LOG_DEFAULT_CHANNEL NULL
|
||||
#define ENABLE_CHANNEL_BY_DEFAULT(ch_name) \
|
||||
static bool COMBINE(init_channel, __LINE__) UNUSED_ATTRIBUTE = epee::misc_utils::static_initializer([](){ \
|
||||
epee::log_space::log_singletone::enable_channel(ch_name); return true; \
|
||||
});
|
||||
|
||||
#if defined(ENABLE_LOGGING_INTERNAL)
|
||||
|
||||
#define LOG_PRINT_CHANNEL_NO_PREFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str() , y, epee::log_space::console_color_default, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL_NO_PREFIX_NO_POSTFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << x; epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL_NO_POSTFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x; epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL_COLOR2(log_channel, log_name, x, y, color) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, color, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL_2_JORNAL(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, true, log_name);}}
|
||||
|
||||
#define LOG_ERROR2(log_name, x) { \
|
||||
std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << "[ERROR] Location: " << std::endl << LOCATION_SS << epee::misc_utils::print_trace() << " Message:" << std::endl << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str(), LOG_LEVEL_0, epee::log_space::console_color_red, true, log_name); LOCAL_ASSERT(0); epee::log_space::increase_error_count(LOG_DEFAULT_CHANNEL); }
|
||||
|
||||
#define LOG_FRAME2(log_name, x, y) epee::log_space::log_frame frame(x, y, log_name)
|
||||
|
||||
#else // #if defined(ENABLE_LOGGING_INTERNAL)
|
||||
|
||||
#define LOG_PRINT_NO_PREFIX2(log_name, x, y)
|
||||
#define LOG_PRINT_NO_PREFIX_NO_POSTFIX2(log_name, x, y)
|
||||
#define LOG_PRINT_NO_POSTFIX2(log_name, x, y)
|
||||
#define LOG_PRINT_COLOR2(log_name, x, y, color)
|
||||
#define LOG_PRINT2_JORNAL(log_name, x, y)
|
||||
#define LOG_PRINT2(log_name, x, y)
|
||||
#define LOG_ERROR2(log_name, x)
|
||||
#define LOG_FRAME2(log_name, x, y)
|
||||
|
||||
#endif // #if defined(ENABLE_LOGGING_INTERNAL)
|
||||
|
||||
#define LOG_PRINT_NO_PREFIX2(log_name, x, y) LOG_PRINT_CHANNEL_NO_PREFIX2(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
#define LOG_PRINT_NO_PREFIX_NO_POSTFIX2(log_name, x, y) LOG_PRINT_CHANNEL_NO_PREFIX_NO_POSTFIX2(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
#define LOG_PRINT_NO_POSTFIX2(log_name, x, y) LOG_PRINT_CHANNEL_NO_POSTFIX2(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
#define LOG_PRINT2(log_name, x, y) LOG_PRINT_CHANNEL2(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
#define LOG_PRINT_COLOR2(log_name, x, y, color) LOG_PRINT_CHANNEL_COLOR2(LOG_DEFAULT_CHANNEL, log_name, x, y, color)
|
||||
#define LOG_PRINT2_JORNAL(log_name, x, y) LOG_PRINT_CHANNEL_2_JORNAL(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
|
||||
#ifndef LOG_DEFAULT_TARGET
|
||||
#define LOG_DEFAULT_TARGET NULL
|
||||
#endif
|
||||
|
||||
#define LOG_PRINT_NO_POSTFIX(mess, level) LOG_PRINT_NO_POSTFIX2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_PRINT_NO_PREFIX(mess, level) LOG_PRINT_NO_PREFIX2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_PRINT_NO_PREFIX_NO_POSTFIX(mess, level) LOG_PRINT_NO_PREFIX_NO_POSTFIX2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_PRINT(mess, level) LOG_PRINT2(LOG_DEFAULT_TARGET, mess, level)
|
||||
|
||||
#define LOG_PRINT_COLOR(mess, level, color) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, color)
|
||||
#define LOG_PRINT_RED(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_red)
|
||||
#define LOG_PRINT_GREEN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_green)
|
||||
#define LOG_PRINT_BLUE(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_blue)
|
||||
#define LOG_PRINT_YELLOW(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_yellow)
|
||||
#define LOG_PRINT_CYAN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_cyan)
|
||||
#define LOG_PRINT_MAGENTA(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_magenta)
|
||||
|
||||
#define LOG_PRINT_RED_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_red)
|
||||
|
||||
#define LOG_PRINT_L0(mess) LOG_PRINT(mess, LOG_LEVEL_0)
|
||||
#define LOG_PRINT_L1(mess) LOG_PRINT(mess, LOG_LEVEL_1)
|
||||
#define LOG_PRINT_L2(mess) LOG_PRINT(mess, LOG_LEVEL_2)
|
||||
#define LOG_PRINT_L3(mess) LOG_PRINT(mess, LOG_LEVEL_3)
|
||||
#define LOG_PRINT_L4(mess) LOG_PRINT(mess, LOG_LEVEL_4)
|
||||
#define LOG_PRINT_J(mess, level) LOG_PRINT2_JORNAL(LOG_DEFAULT_TARGET, mess, level)
|
||||
|
||||
#define LOG_ERROR(mess) LOG_ERROR2(LOG_DEFAULT_TARGET, mess)
|
||||
#define LOG_FRAME(mess, level) LOG_FRAME2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_VALUE(mess, level) LOG_VALUE2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_ARRAY(mess, level) LOG_ARRAY2(LOG_DEFAULT_TARGET, mess, level)
|
||||
//#define LOGWIN_PLATFORM_ERROR(err_no) LOGWINDWOS_PLATFORM_ERROR2(LOG_DEFAULT_TARGET, err_no)
|
||||
#define LOG_SOCKET_ERROR(err_no) LOG_SOCKET_ERROR2(LOG_DEFAULT_TARGET, err_no)
|
||||
//#define LOGWIN_PLATFORM_ERROR_UNCRITICAL(mess) LOGWINDWOS_PLATFORM_ERROR_UNCRITICAL2(LOG_DEFAULT_TARGET, mess)
|
||||
|
||||
#define ENDL std::endl
|
||||
|
||||
#define TRY_ENTRY() try {
|
||||
#define CATCH_ENTRY_CUSTOM(location, custom_code, return_val) } \
|
||||
catch(const std::exception& ex) \
|
||||
{ \
|
||||
(void)(ex); \
|
||||
LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \
|
||||
custom_code; \
|
||||
return return_val; \
|
||||
} \
|
||||
catch(...) \
|
||||
{ \
|
||||
LOG_ERROR("Exception at [" << location << "], generic exception \"...\""); \
|
||||
custom_code; \
|
||||
return return_val; \
|
||||
}
|
||||
#define CATCH_ENTRY(location, return_val) CATCH_ENTRY_CUSTOM(location, (void)0, return_val)
|
||||
#define CATCH_ENTRY2(return_val) CATCH_ENTRY_CUSTOM(LOCATION_SS, (void)0, return_val)
|
||||
|
||||
#define CATCH_ENTRY_L0(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
#define CATCH_ENTRY_L1(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
#define CATCH_ENTRY_L2(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
#define CATCH_ENTRY_L3(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
#define CATCH_ENTRY_L4(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
|
||||
/// @brief Catches TRY_ENTRY without returning
|
||||
/// @details Useful within a dtor - but only if nested within another try block
|
||||
/// (since we can still potentially throw here). See NESTED_*ENTRY()
|
||||
/// @todo Exception dispatcher class
|
||||
#define CATCH_ENTRY_NO_RETURN(location, custom_code) } \
|
||||
catch(const std::exception& ex) \
|
||||
{ \
|
||||
(void)(ex); \
|
||||
LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \
|
||||
custom_code; \
|
||||
} \
|
||||
catch(...) \
|
||||
{ \
|
||||
LOG_ERROR("Exception at [" << location << "], generic exception \"...\""); \
|
||||
custom_code; \
|
||||
}
|
||||
|
||||
#define NESTED_TRY_ENTRY() try { TRY_ENTRY();
|
||||
|
||||
#define NESTED_CATCH_ENTRY(location) \
|
||||
CATCH_ENTRY_NO_RETURN(location, {}); \
|
||||
} catch (...) {}
|
||||
|
||||
#define ASSERT_MES_AND_THROW(message) {LOG_ERROR(message); std::stringstream ss; ss << message; throw std::runtime_error(ss.str());}
|
||||
|
||||
#define CHECK_AND_ASSERT_THROW_MES(expr, message) {if(!(expr)) ASSERT_MES_AND_THROW(message << ENDL << "thrown from " << LOCATION_SS);}
|
||||
#define CHECK_AND_ASSERT_THROW(expr, exception_exp) {if(!(expr)) {LOG_ERROR("EXCEPTION is thrown from " << LOCATION_SS); throw exception_exp; };}
|
||||
|
||||
#ifndef CHECK_AND_ASSERT
|
||||
#define CHECK_AND_ASSERT(expr, fail_ret_val) do{if(!(expr)){LOCAL_ASSERT(expr); return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
#define NOTHING
|
||||
|
||||
#ifndef CHECK_AND_ASSERT_MES
|
||||
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message) do{if(!(expr)) {LOG_ERROR(message); return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_AND_FORCE_ASSERT_MES
|
||||
#define CHECK_AND_FORCE_ASSERT_MES(expr, fail_ret_val, message) do{if(!(expr)) {LOG_ERROR(message); FORCE_ASSERT(expr); return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_AND_ASSERT_MES_CUSTOM
|
||||
#define CHECK_AND_ASSERT_MES_CUSTOM(expr, fail_ret_val, custom_code, message) do{if(!(expr)) {LOG_ERROR(message); custom_code; return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
/*#ifndef CHECK_AND_ASSERT_MES_AND_THROW
|
||||
#define CHECK_AND_ASSERT_MES_AND_THROW(expr, message) do{if(!(expr)) {LOG_ERROR(message); throw std::runtime_error(message);};}while(0)
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifndef CHECK_AND_NO_ASSERT_MES
|
||||
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message) do{if(!(expr)) {LOG_PRINT_MAGENTA(message, LOG_LEVEL_0); /*LOCAL_ASSERT(expr);*/ return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_AND_NO_ASSERT_MES_LEVEL
|
||||
#define CHECK_AND_NO_ASSERT_MES_LEVEL(expr, fail_ret_val, message, log_level) do{if(!(expr)) {LOG_PRINT(message, log_level); return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_AND_ASSERT_MES_NO_RET
|
||||
#define CHECK_AND_ASSERT_MES_NO_RET(expr, message) do{if(!(expr)) {LOG_ERROR(message);};}while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_AND_ASSERT_MES2
|
||||
#define CHECK_AND_ASSERT_MES2(expr, message) do{if(!(expr)) {LOG_ERROR(message); };}while(0)
|
||||
#endif
|
||||
|
||||
namespace epee
|
||||
{
|
||||
|
|
@ -703,7 +885,7 @@ namespace log_space
|
|||
m_log_streams.push_back(streams_container::value_type(ls, log_level_limit));
|
||||
return true;
|
||||
}
|
||||
return ls ? true:false;
|
||||
return false;
|
||||
}
|
||||
bool add_logger( ibase_log_stream* pstream, int log_level_limit = LOG_LEVEL_4 )
|
||||
{
|
||||
|
|
@ -1427,10 +1609,10 @@ POP_WARNINGS
|
|||
}
|
||||
~log_frame()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
#ifdef _MSC_VER
|
||||
int lasterr=::GetLastError();
|
||||
#endif
|
||||
|
||||
if (m_level <= log_singletone::get_log_detalisation_level() )
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
|
@ -1440,6 +1622,7 @@ POP_WARNINGS
|
|||
#ifdef _MSC_VER
|
||||
::SetLastError(lasterr);
|
||||
#endif
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1500,192 +1683,7 @@ POP_WARNINGS
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_RELEASE_LOGGING)
|
||||
#define ENABLE_LOGGING_INTERNAL
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define LOG_DEFAULT_CHANNEL NULL
|
||||
#define ENABLE_CHANNEL_BY_DEFAULT(ch_name) \
|
||||
static bool COMBINE(init_channel, __LINE__) UNUSED_ATTRIBUTE = epee::misc_utils::static_initializer([](){ \
|
||||
epee::log_space::log_singletone::enable_channel(ch_name); return true; \
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(ENABLE_LOGGING_INTERNAL)
|
||||
|
||||
#define LOG_PRINT_CHANNEL_NO_PREFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str() , y, epee::log_space::console_color_default, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL_NO_PREFIX_NO_POSTFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << x; epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL_NO_POSTFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x; epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL_COLOR2(log_channel, log_name, x, y, color) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, color, false, log_name);}}
|
||||
|
||||
#define LOG_PRINT_CHANNEL_2_JORNAL(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\
|
||||
{std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, true, log_name);}}
|
||||
|
||||
|
||||
|
||||
#define LOG_ERROR2(log_name, x) { \
|
||||
std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << "[ERROR] Location: " << std::endl << LOCATION_SS << epee::misc_utils::print_trace() << " Message:" << std::endl << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str(), LOG_LEVEL_0, epee::log_space::console_color_red, true, log_name); LOCAL_ASSERT(0); epee::log_space::increase_error_count(LOG_DEFAULT_CHANNEL); }
|
||||
|
||||
#define LOG_FRAME2(log_name, x, y) epee::log_space::log_frame frame(x, y, log_name)
|
||||
|
||||
#else // #if defined(ENABLE_LOGGING_INTERNAL)
|
||||
|
||||
|
||||
#define LOG_PRINT_NO_PREFIX2(log_name, x, y)
|
||||
|
||||
#define LOG_PRINT_NO_PREFIX_NO_POSTFIX2(log_name, x, y)
|
||||
|
||||
#define LOG_PRINT_NO_POSTFIX2(log_name, x, y)
|
||||
|
||||
#define LOG_PRINT_COLOR2(log_name, x, y, color)
|
||||
|
||||
#define LOG_PRINT2_JORNAL(log_name, x, y)
|
||||
|
||||
#define LOG_PRINT2(log_name, x, y)
|
||||
|
||||
#define LOG_ERROR2(log_name, x)
|
||||
|
||||
|
||||
#define LOG_FRAME2(log_name, x, y)
|
||||
|
||||
|
||||
#endif // #if defined(ENABLE_LOGGING_INTERNAL)
|
||||
|
||||
#define LOG_PRINT_NO_PREFIX2(log_name, x, y) LOG_PRINT_CHANNEL_NO_PREFIX2(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
#define LOG_PRINT_NO_PREFIX_NO_POSTFIX2(log_name, x, y) LOG_PRINT_CHANNEL_NO_PREFIX_NO_POSTFIX2(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
#define LOG_PRINT_NO_POSTFIX2(log_name, x, y) LOG_PRINT_CHANNEL_NO_POSTFIX2(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
#define LOG_PRINT2(log_name, x, y) LOG_PRINT_CHANNEL2(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
#define LOG_PRINT_COLOR2(log_name, x, y, color) LOG_PRINT_CHANNEL_COLOR2(LOG_DEFAULT_CHANNEL, log_name, x, y, color)
|
||||
#define LOG_PRINT2_JORNAL(log_name, x, y) LOG_PRINT_CHANNEL_2_JORNAL(LOG_DEFAULT_CHANNEL, log_name, x, y)
|
||||
|
||||
|
||||
|
||||
#ifndef LOG_DEFAULT_TARGET
|
||||
#define LOG_DEFAULT_TARGET NULL
|
||||
#endif
|
||||
|
||||
|
||||
#define LOG_PRINT_NO_POSTFIX(mess, level) LOG_PRINT_NO_POSTFIX2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_PRINT_NO_PREFIX(mess, level) LOG_PRINT_NO_PREFIX2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_PRINT_NO_PREFIX_NO_POSTFIX(mess, level) LOG_PRINT_NO_PREFIX_NO_POSTFIX2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_PRINT(mess, level) LOG_PRINT2(LOG_DEFAULT_TARGET, mess, level)
|
||||
|
||||
#define LOG_PRINT_COLOR(mess, level, color) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, color)
|
||||
#define LOG_PRINT_RED(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_red)
|
||||
#define LOG_PRINT_GREEN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_green)
|
||||
#define LOG_PRINT_BLUE(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_blue)
|
||||
#define LOG_PRINT_YELLOW(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_yellow)
|
||||
#define LOG_PRINT_CYAN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_cyan)
|
||||
#define LOG_PRINT_MAGENTA(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_magenta)
|
||||
|
||||
#define LOG_PRINT_RED_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_red)
|
||||
|
||||
#define LOG_PRINT_L0(mess) LOG_PRINT(mess, LOG_LEVEL_0)
|
||||
#define LOG_PRINT_L1(mess) LOG_PRINT(mess, LOG_LEVEL_1)
|
||||
#define LOG_PRINT_L2(mess) LOG_PRINT(mess, LOG_LEVEL_2)
|
||||
#define LOG_PRINT_L3(mess) LOG_PRINT(mess, LOG_LEVEL_3)
|
||||
#define LOG_PRINT_L4(mess) LOG_PRINT(mess, LOG_LEVEL_4)
|
||||
#define LOG_PRINT_J(mess, level) LOG_PRINT2_JORNAL(LOG_DEFAULT_TARGET, mess, level)
|
||||
|
||||
#define LOG_ERROR(mess) LOG_ERROR2(LOG_DEFAULT_TARGET, mess)
|
||||
#define LOG_FRAME(mess, level) LOG_FRAME2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_VALUE(mess, level) LOG_VALUE2(LOG_DEFAULT_TARGET, mess, level)
|
||||
#define LOG_ARRAY(mess, level) LOG_ARRAY2(LOG_DEFAULT_TARGET, mess, level)
|
||||
//#define LOGWIN_PLATFORM_ERROR(err_no) LOGWINDWOS_PLATFORM_ERROR2(LOG_DEFAULT_TARGET, err_no)
|
||||
#define LOG_SOCKET_ERROR(err_no) LOG_SOCKET_ERROR2(LOG_DEFAULT_TARGET, err_no)
|
||||
//#define LOGWIN_PLATFORM_ERROR_UNCRITICAL(mess) LOGWINDWOS_PLATFORM_ERROR_UNCRITICAL2(LOG_DEFAULT_TARGET, mess)
|
||||
|
||||
#define ENDL std::endl
|
||||
|
||||
#define TRY_ENTRY() try {
|
||||
#define CATCH_ENTRY_CUSTOM(location, custom_code, return_val) } \
|
||||
catch(const std::exception& ex) \
|
||||
{ \
|
||||
(void)(ex); \
|
||||
LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \
|
||||
custom_code; \
|
||||
return return_val; \
|
||||
} \
|
||||
catch(...) \
|
||||
{ \
|
||||
LOG_ERROR("Exception at [" << location << "], generic exception \"...\""); \
|
||||
custom_code; \
|
||||
return return_val; \
|
||||
}
|
||||
#define CATCH_ENTRY(location, return_val) CATCH_ENTRY_CUSTOM(location, (void)0, return_val)
|
||||
|
||||
#define CATCH_ENTRY2(return_val) CATCH_ENTRY_CUSTOM(LOCATION_SS, (void)0, return_val)
|
||||
|
||||
#define CATCH_ENTRY_L0(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
#define CATCH_ENTRY_L1(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
#define CATCH_ENTRY_L2(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
#define CATCH_ENTRY_L3(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
#define CATCH_ENTRY_L4(location, return_val) CATCH_ENTRY(location, return_val)
|
||||
|
||||
|
||||
#define ASSERT_MES_AND_THROW(message) {LOG_ERROR(message); std::stringstream ss; ss << message; throw std::runtime_error(ss.str());}
|
||||
|
||||
#define CHECK_AND_ASSERT_THROW_MES(expr, message) {if(!(expr)) ASSERT_MES_AND_THROW(message << ENDL << "thrown from " << LOCATION_SS);}
|
||||
#define CHECK_AND_ASSERT_THROW(expr, exception_exp) {if(!(expr)) {LOG_ERROR("EXCEPTION is thrown from " << LOCATION_SS); throw exception_exp; };}
|
||||
|
||||
|
||||
#ifndef CHECK_AND_ASSERT
|
||||
#define CHECK_AND_ASSERT(expr, fail_ret_val) do{if(!(expr)){LOCAL_ASSERT(expr); return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
#define NOTHING
|
||||
|
||||
#ifndef CHECK_AND_ASSERT_MES
|
||||
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message) do{if(!(expr)) {LOG_ERROR(message); return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_AND_FORCE_ASSERT_MES
|
||||
#define CHECK_AND_FORCE_ASSERT_MES(expr, fail_ret_val, message) do{if(!(expr)) {LOG_ERROR(message); FORCE_ASSERT(expr); return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef CHECK_AND_ASSERT_MES_CUSTOM
|
||||
#define CHECK_AND_ASSERT_MES_CUSTOM(expr, fail_ret_val, custom_code, message) do{if(!(expr)) {LOG_ERROR(message); custom_code; return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
/*#ifndef CHECK_AND_ASSERT_MES_AND_THROW
|
||||
#define CHECK_AND_ASSERT_MES_AND_THROW(expr, message) do{if(!(expr)) {LOG_ERROR(message); throw std::runtime_error(message);};}while(0)
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifndef CHECK_AND_NO_ASSERT_MES
|
||||
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message) do{if(!(expr)) {LOG_PRINT_MAGENTA(message, LOG_LEVEL_0); /*LOCAL_ASSERT(expr);*/ return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_AND_NO_ASSERT_MES_LEVEL
|
||||
#define CHECK_AND_NO_ASSERT_MES_LEVEL(expr, fail_ret_val, message, log_level) do{if(!(expr)) {LOG_PRINT(message, log_level); return fail_ret_val;};}while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_AND_ASSERT_MES_NO_RET
|
||||
#define CHECK_AND_ASSERT_MES_NO_RET(expr, message) do{if(!(expr)) {LOG_ERROR(message);};}while(0)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef CHECK_AND_ASSERT_MES2
|
||||
#define CHECK_AND_ASSERT_MES2(expr, message) do{if(!(expr)) {LOG_ERROR(message); };}while(0)
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace epee
|
||||
|
||||
POP_WARNINGS
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2019, anonimal, <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -185,7 +186,7 @@ class boosted_tcp_server
|
|||
|
||||
bool connect(const std::string& adr, const std::string& port, uint32_t conn_timeot, t_connection_context& cn, const std::string& bind_ip = "0.0.0.0");
|
||||
template<class t_callback>
|
||||
bool connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeot, t_callback cb, const std::string& bind_ip = "0.0.0.0");
|
||||
bool connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeot, const t_callback& cb, const std::string& bind_ip = "0.0.0.0");
|
||||
|
||||
typename t_protocol_handler::config_type& get_config_object()
|
||||
{
|
||||
|
|
@ -311,4 +312,4 @@ class boosted_tcp_server
|
|||
#undef LOG_DEFAULT_CHANNEL
|
||||
#define LOG_DEFAULT_CHANNEL NULL
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2019, anonimal <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -53,7 +54,8 @@ connection<t_protocol_handler>::connection(boost::asio::io_service& io_service,
|
|||
m_want_close_connection(0),
|
||||
m_was_shutdown(0),
|
||||
m_ref_sockets_count(sock_count),
|
||||
m_pfilter(pfilter)
|
||||
m_pfilter(pfilter),
|
||||
m_is_multithreaded(false)
|
||||
{
|
||||
boost::interprocess::ipcdetail::atomic_inc32(&m_ref_sockets_count);
|
||||
}
|
||||
|
|
@ -62,6 +64,8 @@ DISABLE_VS_WARNINGS(4355)
|
|||
template<class t_protocol_handler>
|
||||
connection<t_protocol_handler>::~connection()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
if(!m_was_shutdown) {
|
||||
LOG_PRINT_L3("[sock " << socket_.native_handle() << "] Socket destroyed without shutdown.");
|
||||
shutdown();
|
||||
|
|
@ -71,6 +75,8 @@ connection<t_protocol_handler>::~connection()
|
|||
boost::interprocess::ipcdetail::atomic_dec32(&m_ref_sockets_count);
|
||||
VALIDATE_MUTEX_IS_FREE(m_send_que_lock);
|
||||
VALIDATE_MUTEX_IS_FREE(m_self_refs_lock);
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
template<class t_protocol_handler>
|
||||
|
|
@ -435,8 +441,12 @@ boosted_tcp_server<t_protocol_handler>::boosted_tcp_server(boost::asio::io_servi
|
|||
template<class t_protocol_handler>
|
||||
boosted_tcp_server<t_protocol_handler>::~boosted_tcp_server()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
this->send_stop_signal();
|
||||
timed_wait_server_stop(10000);
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
template<class t_protocol_handler>
|
||||
|
|
@ -716,7 +726,7 @@ bool boosted_tcp_server<t_protocol_handler>::connect(const std::string& adr, con
|
|||
//---------------------------------------------------------------------------------
|
||||
template<class t_protocol_handler>
|
||||
template<class t_callback>
|
||||
bool boosted_tcp_server<t_protocol_handler>::connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeout, t_callback cb, const std::string& bind_ip)
|
||||
bool boosted_tcp_server<t_protocol_handler>::connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeout, const t_callback& cb, const std::string& bind_ip)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
connection_ptr new_connection_l(new connection<t_protocol_handler>(io_service_, m_config, m_sockets_count, m_pfilter));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2019, anonimal, <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -137,7 +138,8 @@ namespace net_utils
|
|||
http_request_info():m_http_method(http_method_unknown),
|
||||
m_http_ver_hi(0),
|
||||
m_http_ver_lo(0),
|
||||
m_have_to_block(false)
|
||||
m_have_to_block(false),
|
||||
m_full_request_buf_size{}
|
||||
{}
|
||||
|
||||
http_method m_http_method;
|
||||
|
|
@ -181,4 +183,4 @@ namespace net_utils
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2019, anonimal <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -76,7 +77,7 @@ public:
|
|||
void on_send_stop_signal();
|
||||
int invoke(int command, const std::string& in_buff, std::string& buff_out, boost::uuids::uuid connection_id);
|
||||
template<class callback_t>
|
||||
int invoke_async(int command, const std::string& in_buff, boost::uuids::uuid connection_id, callback_t cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED);
|
||||
int invoke_async(int command, const std::string& in_buff, boost::uuids::uuid connection_id, const callback_t& cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED);
|
||||
|
||||
int notify(int command, const std::string& in_buff, boost::uuids::uuid connection_id);
|
||||
bool close(boost::uuids::uuid connection_id);
|
||||
|
|
@ -86,14 +87,17 @@ public:
|
|||
bool foreach_connection(callback_t cb);
|
||||
size_t get_connections_count();
|
||||
|
||||
async_protocol_handler_config() :m_pcommands_handler(NULL), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_is_in_sendstop_loop(false)
|
||||
async_protocol_handler_config() :m_pcommands_handler(NULL), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_is_in_sendstop_loop(false), m_invoke_timeout{}
|
||||
{}
|
||||
~async_protocol_handler_config()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
CRITICAL_REGION_LOCAL(m_connects_lock);
|
||||
m_connects.clear();
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -213,7 +217,7 @@ public:
|
|||
std::list<boost::shared_ptr<invoke_response_handler_base> > m_invoke_response_handlers;
|
||||
|
||||
template<class callback_t>
|
||||
bool add_invoke_response_handler(callback_t cb, uint64_t timeout, async_protocol_handler& con, int command)
|
||||
bool add_invoke_response_handler(const callback_t& cb, uint64_t timeout, async_protocol_handler& con, int command)
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(m_invoke_response_handlers_lock);
|
||||
boost::shared_ptr<invoke_response_handler_base> handler(boost::make_shared<invoke_handler<callback_t>>(cb, timeout, con, command));
|
||||
|
|
@ -226,6 +230,8 @@ public:
|
|||
async_protocol_handler(net_utils::i_service_endpoint* psnd_hndlr,
|
||||
config_type& config,
|
||||
t_connection_context& conn_context):
|
||||
m_invoke_buf_ready{},
|
||||
m_invoke_result_code{},
|
||||
m_current_head(bucket_head2()),
|
||||
m_pservice_endpoint(psnd_hndlr),
|
||||
m_config(config),
|
||||
|
|
@ -243,6 +249,8 @@ public:
|
|||
|
||||
virtual ~async_protocol_handler()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
m_deletion_initiated = true;
|
||||
if(m_connection_initialized)
|
||||
{
|
||||
|
|
@ -261,6 +269,8 @@ public:
|
|||
VALIDATE_MUTEX_IS_FREE(m_send_lock);
|
||||
VALIDATE_MUTEX_IS_FREE(m_call_lock);
|
||||
VALIDATE_MUTEX_IS_FREE(m_invoke_response_handlers_lock);
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
bool start_outer_call()
|
||||
|
|
@ -529,7 +539,7 @@ public:
|
|||
}
|
||||
|
||||
template<class callback_t>
|
||||
bool async_invoke(int command, const std::string& in_buff, callback_t cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
|
||||
bool async_invoke(int command, const std::string& in_buff, const callback_t& cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
|
||||
{
|
||||
misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler(
|
||||
boost::bind(&async_protocol_handler::finish_outer_call, this));
|
||||
|
|
@ -784,7 +794,7 @@ int async_protocol_handler_config<t_connection_context>::invoke(int command, con
|
|||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
template<class t_connection_context> template<class callback_t>
|
||||
int async_protocol_handler_config<t_connection_context>::invoke_async(int command, const std::string& in_buff, boost::uuids::uuid connection_id, callback_t cb, size_t timeout)
|
||||
int async_protocol_handler_config<t_connection_context>::invoke_async(int command, const std::string& in_buff, boost::uuids::uuid connection_id, const callback_t& cb, size_t timeout)
|
||||
{
|
||||
async_protocol_handler<t_connection_context>* aph;
|
||||
int r = find_and_lock_connection(connection_id, aph);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2019, anonimal, <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -85,7 +86,9 @@ namespace net_utils
|
|||
m_initialized(false),
|
||||
m_connected(false),
|
||||
m_deadline(m_io_service),
|
||||
m_shutdowned(0)
|
||||
m_shutdowned(0),
|
||||
m_connect_timeout{},
|
||||
m_reciev_timeout{}
|
||||
{
|
||||
|
||||
|
||||
|
|
@ -104,9 +107,13 @@ namespace net_utils
|
|||
inline
|
||||
~blocked_mode_client()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
//profile_tools::local_coast lc("~blocked_mode_client()", 3);
|
||||
shutdown();
|
||||
}
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
inline void set_recv_timeout(int reciev_timeout)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2019, anonimal <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -106,16 +107,20 @@ namespace profile_tools
|
|||
}
|
||||
~local_call_account()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
LOG_PRINT2("profile_details.log", "PROFILE "<< std::left << std::setw(50) << (m_name + ":")
|
||||
<< "av_time:" << std::setw(15) << epee::string_tools::print_fixed_decimal_point (m_count_of_call ? (m_summary_time_used / m_count_of_call) : 0, 3)
|
||||
<< "sum_time: " << std::setw(15) << epee::string_tools::print_fixed_decimal_point(m_summary_time_used, 3)
|
||||
<< "call_count: " << std::setw(15) << m_count_of_call, LOG_LEVEL_0);
|
||||
}
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
size_t m_count_of_call;
|
||||
uint64_t m_summary_time_used;
|
||||
std::string m_name;
|
||||
};
|
||||
};
|
||||
|
||||
struct call_frame
|
||||
{
|
||||
|
|
@ -124,17 +129,21 @@ namespace profile_tools
|
|||
{
|
||||
m_call_time = boost::posix_time::microsec_clock::local_time();
|
||||
}
|
||||
|
||||
~call_frame()
|
||||
{
|
||||
boost::posix_time::ptime now_t(boost::posix_time::microsec_clock::local_time());
|
||||
boost::posix_time::time_duration delta_microsec = now_t - m_call_time;
|
||||
uint64_t microseconds_used = delta_microsec.total_microseconds();
|
||||
m_cc.m_summary_time_used += microseconds_used;
|
||||
m_cc.m_count_of_call++;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
~call_frame()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
boost::posix_time::ptime now_t(boost::posix_time::microsec_clock::local_time());
|
||||
boost::posix_time::time_duration delta_microsec = now_t - m_call_time;
|
||||
uint64_t microseconds_used = delta_microsec.total_microseconds();
|
||||
m_cc.m_summary_time_used += microseconds_used;
|
||||
m_cc.m_count_of_call++;
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
private:
|
||||
local_call_account& m_cc;
|
||||
boost::posix_time::ptime m_call_time;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2019, anonimal, <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -114,7 +115,7 @@ namespace epee
|
|||
}
|
||||
|
||||
template<class t_result, class t_arg, class callback_t, class t_transport>
|
||||
bool async_invoke_remote_command2(boost::uuids::uuid conn_id, int command, const t_arg& out_struct, t_transport& transport, callback_t cb, size_t inv_timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
|
||||
bool async_invoke_remote_command2(boost::uuids::uuid conn_id, int command, const t_arg& out_struct, t_transport& transport, const callback_t& cb, size_t inv_timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
|
||||
{
|
||||
typename serialization::portable_storage stg;
|
||||
const_cast<t_arg&>(out_struct).store(stg);//TODO: add true const support to searilzation
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// Copyright (c) 2019, anonimal, <anonimal@zano.org>
|
||||
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -604,8 +605,14 @@ namespace epee
|
|||
|
||||
~guarded_critical_region_t()
|
||||
{
|
||||
// TODO(unassigned): because one cannot forward-declare macros,
|
||||
// the circular dependency created by misc_log_ex will not
|
||||
// allow us to actually use these substitutions.
|
||||
//NESTED_TRY_ENTRY();
|
||||
|
||||
unlock();
|
||||
|
||||
//NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
void unlock()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Boolberry developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -725,7 +725,11 @@ namespace tools
|
|||
}
|
||||
~cached_key_value_accessor()
|
||||
{
|
||||
m_cache.clear(); //will clear cache isolated
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
m_cache.clear(); //will clear cache isolated
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
void clear_cache() const
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
|
@ -26,7 +26,11 @@ namespace tools
|
|||
}
|
||||
lmdb_db_backend::~lmdb_db_backend()
|
||||
{
|
||||
close();
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
close();
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
bool lmdb_db_backend::open(const std::string& path_, uint64_t cache_sz)
|
||||
|
|
@ -363,4 +367,4 @@ namespace tools
|
|||
}
|
||||
|
||||
#undef LOG_DEFAULT_CHANNEL
|
||||
#define LOG_DEFAULT_CHANNEL NULL
|
||||
#define LOG_DEFAULT_CHANNEL NULL
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Boolberry developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -35,13 +35,18 @@ namespace tools
|
|||
miniupnp_helper():m_devlist(nullptr),
|
||||
m_urls(AUTO_VAL_INIT(m_urls)),
|
||||
m_data(AUTO_VAL_INIT(m_data)),
|
||||
m_IGD(0)
|
||||
m_IGD(0),
|
||||
m_external_port{}
|
||||
{
|
||||
m_lanaddr[0] = 0;
|
||||
}
|
||||
~miniupnp_helper()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
deinit();
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
bool start_regular_mapping(uint32_t internal_port, uint32_t external_port, uint32_t period_ms)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -24,6 +24,7 @@ using namespace epee;
|
|||
#include "net/http_client.h"
|
||||
#include "currency_core/genesis_acc.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace po = boost::program_options;
|
||||
using namespace currency;
|
||||
|
|
@ -1037,6 +1038,9 @@ bool handle_download_peer_log(po::variables_map& vm)
|
|||
//---------------------------------------------------------------------------------------------------------------
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
string_tools::set_module_name_and_folder(argv[0]);
|
||||
log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
|
||||
|
|
@ -1072,9 +1076,6 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_params, arg_set_peer_log_level);
|
||||
command_line::add_arg(desc_params, arg_download_peer_log);
|
||||
command_line::add_arg(desc_params, arg_do_consloe_log);
|
||||
|
||||
|
||||
|
||||
|
||||
po::options_description desc_all;
|
||||
desc_all.add(desc_general).add(desc_params);
|
||||
|
|
@ -1095,7 +1096,7 @@ int main(int argc, char* argv[])
|
|||
return true;
|
||||
});
|
||||
if (!r)
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if (command_line::has_arg(vm, arg_do_consloe_log) && command_line::get_arg(vm, arg_do_consloe_log))
|
||||
{
|
||||
log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
|
||||
|
|
@ -1105,43 +1106,43 @@ int main(int argc, char* argv[])
|
|||
if (command_line::get_arg(vm, command_line::arg_version))
|
||||
{
|
||||
std::cout << CURRENCY_NAME << " v" << PROJECT_VERSION_LONG << ENDL;
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if(command_line::has_arg(vm, arg_request_stat_info) || command_line::has_arg(vm, arg_request_net_state))
|
||||
{
|
||||
return handle_request_stat(vm, command_line::get_arg(vm, arg_peer_id)) ? 0:1;
|
||||
return handle_request_stat(vm, command_line::get_arg(vm, arg_peer_id)) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
if(command_line::has_arg(vm, arg_get_daemon_info))
|
||||
{
|
||||
return handle_get_daemon_info(vm) ? 0:1;
|
||||
return handle_get_daemon_info(vm) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
else if(command_line::has_arg(vm, arg_generate_keys))
|
||||
{
|
||||
return generate_and_print_keys() ? 0:1;
|
||||
return generate_and_print_keys() ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
else if(command_line::has_arg(vm, arg_get_aliases))
|
||||
{
|
||||
return handle_get_aliases(vm) ? 0:1;
|
||||
return handle_get_aliases(vm) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
else if(command_line::has_arg(vm, arg_upate_maintainers_info))
|
||||
{
|
||||
return handle_update_maintainers_info(vm) ? 0:1;
|
||||
return handle_update_maintainers_info(vm) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
else if (command_line::has_arg(vm, arg_increment_build_no))
|
||||
{
|
||||
return handle_increment_build_no(vm) ? 0 : 1;
|
||||
return handle_increment_build_no(vm) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
else if (command_line::has_arg(vm, arg_generate_genesis))
|
||||
{
|
||||
return generate_genesis(command_line::get_arg(vm, arg_generate_genesis), 10000000000000000) ? 0 : 1;
|
||||
return generate_genesis(command_line::get_arg(vm, arg_generate_genesis), 10000000000000000) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
else if (command_line::has_arg(vm, arg_set_peer_log_level))
|
||||
{
|
||||
return handle_set_peer_log_level(vm) ? 0 : 1;
|
||||
return handle_set_peer_log_level(vm) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
else if (command_line::has_arg(vm, arg_download_peer_log))
|
||||
{
|
||||
return handle_download_peer_log(vm) ? 0 : 1;
|
||||
return handle_download_peer_log(vm) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1149,6 +1150,13 @@ int main(int argc, char* argv[])
|
|||
std::cerr << desc_all << ENDL;
|
||||
}
|
||||
|
||||
return 1;
|
||||
CATCH_ENTRY_L0(__func__, EXIT_FAILURE);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -141,8 +141,11 @@ namespace crypto {
|
|||
{
|
||||
ge_p3 A = ge_p3();
|
||||
ge_p2 R = ge_p2();
|
||||
// maybe use assert instead?
|
||||
ge_frombytes_vartime(&A, reinterpret_cast<const unsigned char*>(&P));
|
||||
if (ge_frombytes_vartime(&A, reinterpret_cast<const unsigned char*>(&P)) != 0)
|
||||
{
|
||||
assert(false);
|
||||
throw std::runtime_error(__func__);
|
||||
}
|
||||
ge_scalarmult(&R, reinterpret_cast<const unsigned char*>(&a), &A);
|
||||
key_image a_p = key_image();
|
||||
ge_tobytes(reinterpret_cast<unsigned char*>(&a_p), &R);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Copyright (c) 2014-2015 The Boolberry developers
|
||||
|
|
@ -389,7 +389,7 @@ namespace currency
|
|||
{
|
||||
public:
|
||||
// tx version information
|
||||
size_t version;
|
||||
size_t version{};
|
||||
//extra
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<txin_v> vin;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ using namespace epee;
|
|||
#include "version.h"
|
||||
#include "currency_core/core_tools.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <crtdbg.h>
|
||||
#pragma comment(lib, "ntdll") // <-- why do we need this?
|
||||
|
|
@ -43,6 +45,10 @@ bool command_line_preprocessor(const boost::program_options::variables_map& vm);
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
string_tools::set_module_name_and_folder(argv[0]);
|
||||
#ifdef WIN32
|
||||
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
||||
|
|
@ -59,8 +65,6 @@ int main(int argc, char* argv[])
|
|||
std::fflush(nullptr); // all open output streams are flushed
|
||||
});
|
||||
|
||||
TRY_ENTRY();
|
||||
|
||||
po::options_description desc_cmd_only("Command line options");
|
||||
po::options_description desc_cmd_sett("Command line options and settings options", 130, 83);
|
||||
|
||||
|
|
@ -77,7 +81,7 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_cmd_sett, command_line::arg_console);
|
||||
command_line::add_arg(desc_cmd_sett, command_line::arg_show_details);
|
||||
command_line::add_arg(desc_cmd_sett, command_line::arg_show_rpc_autodoc);
|
||||
|
||||
|
||||
|
||||
arg_market_disable.default_value = true;
|
||||
arg_market_disable.not_use_default = false;
|
||||
|
|
@ -125,7 +129,7 @@ int main(int argc, char* argv[])
|
|||
return true;
|
||||
});
|
||||
if (!r)
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
//set up logging options
|
||||
std::string log_dir;
|
||||
|
|
@ -145,7 +149,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (command_line_preprocessor(vm))
|
||||
{
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -173,7 +177,7 @@ int main(int argc, char* argv[])
|
|||
LOG_PRINT_L0("Dumping RPC auto-generated documents!");
|
||||
epee::net_utils::http::http_request_info query_info;
|
||||
epee::net_utils::http::http_response_info response_info;
|
||||
epee::net_utils::connection_context_base conn_context;
|
||||
epee::net_utils::connection_context_base conn_context;
|
||||
std::string generate_reference = std::string("RPC_COMMANDS_LIST:\n");
|
||||
bool call_found = false;
|
||||
rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, generate_reference);
|
||||
|
|
@ -224,7 +228,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
auto& bcs = ccore.get_blockchain_storage();
|
||||
if (!offers_service.is_disabled() && bcs.get_current_blockchain_size() > 1 && bcs.get_top_block_id() != offers_service.get_last_seen_block_id())
|
||||
{
|
||||
|
|
@ -305,9 +309,14 @@ int main(int argc, char* argv[])
|
|||
cprotocol.set_p2p_endpoint(NULL);
|
||||
|
||||
LOG_PRINT("Node stopped.", LOG_LEVEL_0);
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
CATCH_ENTRY_L0("main", 1);
|
||||
CATCH_ENTRY_L0(__func__, EXIT_FAILURE);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
bool command_line_preprocessor(const boost::program_options::variables_map& vm)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -70,7 +70,17 @@ namespace nodetool
|
|||
m_alert_mode(0),
|
||||
m_maintainers_entry_local(AUTO_VAL_INIT(m_maintainers_entry_local)),
|
||||
m_maintainers_info_local(AUTO_VAL_INIT(m_maintainers_info_local)),
|
||||
m_startup_time(time(nullptr))
|
||||
m_startup_time(time(nullptr)),
|
||||
m_config{},
|
||||
m_have_address(false),
|
||||
m_first_connection_maker_call(false),
|
||||
m_listenning_port{},
|
||||
m_external_port{},
|
||||
m_ip_address{},
|
||||
m_last_stat_request_time{},
|
||||
m_use_only_priority_peers(false),
|
||||
m_peer_livetime{}
|
||||
|
||||
{}
|
||||
|
||||
static void init_options(boost::program_options::options_description& desc);
|
||||
|
|
@ -188,7 +198,7 @@ namespace nodetool
|
|||
bool is_peer_used(const peerlist_entry& peer);
|
||||
bool is_addr_connected(const net_address& peer);
|
||||
template<class t_callback>
|
||||
bool try_ping(basic_node_data& node_data, p2p_connection_context& context, t_callback cb);
|
||||
bool try_ping(basic_node_data& node_data, p2p_connection_context& context, const t_callback& cb);
|
||||
bool make_expected_connections_count(bool white_list, size_t expected_connections);
|
||||
void cache_connect_fail_info(const net_address& addr);
|
||||
bool is_addr_recently_failed(const net_address& addr);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -190,8 +190,6 @@ namespace nodetool
|
|||
}
|
||||
if(command_line::has_arg(vm, arg_p2p_use_only_priority_nodes))
|
||||
m_use_only_priority_peers = true;
|
||||
else
|
||||
m_use_only_priority_peers = false;
|
||||
|
||||
|
||||
if (command_line::has_arg(vm, arg_p2p_seed_node))
|
||||
|
|
@ -1182,7 +1180,7 @@ namespace nodetool
|
|||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler> template<class t_callback>
|
||||
bool node_server<t_payload_net_handler>::try_ping(basic_node_data& node_data, p2p_connection_context& context, t_callback cb)
|
||||
bool node_server<t_payload_net_handler>::try_ping(basic_node_data& node_data, p2p_connection_context& context, const t_callback& cb)
|
||||
{
|
||||
if(!node_data.my_port)
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -140,7 +140,7 @@ namespace nodetool
|
|||
friend class boost::serialization::access;
|
||||
epee::critical_section m_peerlist_lock;
|
||||
std::string m_config_folder;
|
||||
bool m_allow_local_ip;
|
||||
bool m_allow_local_ip = false;
|
||||
|
||||
|
||||
peers_indexed m_peers_gray;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2014-2019 The Zano Project
|
||||
// Copyright (c) 2014-2017 The The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -73,7 +74,7 @@ struct json_archive;
|
|||
template <>
|
||||
struct json_archive<true> : public json_archive_base<std::ostream, true>
|
||||
{
|
||||
json_archive(stream_type &s, bool indent = false) : base_type(s, indent) { }
|
||||
json_archive(stream_type &s, bool indent = false) : base_type(s, indent), inner_array_size_{} { }
|
||||
|
||||
template<typename T>
|
||||
static auto promote_to_printable_integer_type(T v) -> decltype(+v)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -21,6 +21,8 @@
|
|||
#include "version.h"
|
||||
#include "string_coding.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
|
@ -95,6 +97,7 @@ namespace
|
|||
#endif
|
||||
, m_color(std::move(rhs.m_color))
|
||||
, m_log_level(std::move(rhs.m_log_level))
|
||||
, m_bright(false)
|
||||
{
|
||||
rhs.m_flush = false;
|
||||
}
|
||||
|
|
@ -108,24 +111,28 @@ namespace
|
|||
|
||||
~message_writer()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
if (m_flush)
|
||||
{
|
||||
m_flush = false;
|
||||
|
||||
LOG_PRINT(m_oss.str(), m_log_level)
|
||||
|
||||
if (epee::log_space::console_color_default == m_color)
|
||||
{
|
||||
std::cout << m_oss.str();
|
||||
m_flush = false;
|
||||
|
||||
LOG_PRINT(m_oss.str(), m_log_level)
|
||||
|
||||
if (epee::log_space::console_color_default == m_color)
|
||||
{
|
||||
std::cout << m_oss.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
epee::log_space::set_console_color(m_color, m_bright);
|
||||
std::cout << m_oss.str();
|
||||
epee::log_space::reset_console_color();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
epee::log_space::set_console_color(m_color, m_bright);
|
||||
std::cout << m_oss.str();
|
||||
epee::log_space::reset_console_color();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -1408,6 +1415,10 @@ bool simple_wallet::submit_transfer(const std::vector<std::string> &args)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
#ifdef WIN32
|
||||
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
||||
#endif
|
||||
|
|
@ -1419,8 +1430,6 @@ int main(int argc, char* argv[])
|
|||
std::fflush(nullptr);
|
||||
});
|
||||
|
||||
//TRY_ENTRY();
|
||||
|
||||
string_tools::set_module_name_and_folder(argv[0]);
|
||||
|
||||
po::options_description desc_general("General options");
|
||||
|
|
@ -1444,7 +1453,7 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_params, command_line::arg_log_file);
|
||||
command_line::add_arg(desc_params, command_line::arg_log_level);
|
||||
|
||||
|
||||
|
||||
tools::wallet_rpc_server::init_options(desc_params);
|
||||
|
||||
po::positional_options_description positional_options;
|
||||
|
|
@ -1476,7 +1485,7 @@ int main(int argc, char* argv[])
|
|||
return true;
|
||||
});
|
||||
if (!r)
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
//set up logging options
|
||||
log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
|
||||
|
|
@ -1498,7 +1507,7 @@ int main(int argc, char* argv[])
|
|||
LOG_PRINT_L0("Setting log level = " << command_line::get_arg(vm, command_line::arg_log_level));
|
||||
log_space::get_set_log_detalisation_level(true, command_line::get_arg(vm, command_line::arg_log_level));
|
||||
}
|
||||
|
||||
|
||||
bool offline_mode = command_line::get_arg(vm, arg_offline_mode);
|
||||
|
||||
if(command_line::has_arg(vm, tools::wallet_rpc_server::arg_rpc_bind_port))
|
||||
|
|
@ -1511,19 +1520,19 @@ int main(int argc, char* argv[])
|
|||
if (!command_line::has_arg(vm, arg_wallet_file) || command_line::get_arg(vm, arg_wallet_file).empty())
|
||||
{
|
||||
LOG_ERROR("Wallet file is not set.");
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!command_line::has_arg(vm, arg_daemon_address) && !command_line::has_arg(vm, arg_offline_mode))
|
||||
{
|
||||
LOG_ERROR("Daemon address is not set.");
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!command_line::has_arg(vm, arg_password) )
|
||||
{
|
||||
LOG_ERROR("Wallet password is not set.");
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::string wallet_file = command_line::get_arg(vm, arg_wallet_file);
|
||||
|
|
@ -1554,7 +1563,7 @@ int main(int argc, char* argv[])
|
|||
catch (const std::exception& e)
|
||||
{
|
||||
LOG_ERROR("Wallet initialize failed: " << e.what());
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1566,7 +1575,7 @@ int main(int argc, char* argv[])
|
|||
LOG_PRINT_L0("Initializing wallet...");
|
||||
wal.init(daemon_address);
|
||||
if (command_line::get_arg(vm, arg_generate_new_wallet).size())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
if (!offline_mode)
|
||||
wal.refresh();
|
||||
LOG_PRINT_GREEN("Loaded ok", LOG_LEVEL_0);
|
||||
|
|
@ -1574,7 +1583,7 @@ int main(int argc, char* argv[])
|
|||
catch (const std::exception& e)
|
||||
{
|
||||
LOG_ERROR("Wallet initialize failed: " << e.what());
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1582,7 +1591,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
tools::wallet_rpc_server wrpc(wal);
|
||||
bool r = wrpc.init(vm);
|
||||
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize wallet rpc server");
|
||||
CHECK_AND_ASSERT_MES(r, EXIT_FAILURE, "Failed to initialize wallet rpc server");
|
||||
|
||||
tools::signal_handler::install([&wrpc/*, &wal*/ /* TODO(unassigned): use? */] {
|
||||
wrpc.send_stop_signal();
|
||||
|
|
@ -1599,16 +1608,16 @@ int main(int argc, char* argv[])
|
|||
catch (const std::exception& e)
|
||||
{
|
||||
LOG_ERROR("Failed to store wallet: " << e.what());
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}else
|
||||
{
|
||||
//runs wallet with console interface
|
||||
//runs wallet with console interface
|
||||
sw->set_offline_mode(offline_mode);
|
||||
r = sw->init(vm);
|
||||
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize wallet");
|
||||
if (command_line::get_arg(vm, arg_generate_new_wallet).size())
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
|
||||
std::vector<std::string> command = command_line::get_arg(vm, arg_command);
|
||||
|
|
@ -1628,6 +1637,12 @@ int main(int argc, char* argv[])
|
|||
sw->deinit();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
//CATCH_ENTRY_L0("main", 1);
|
||||
|
||||
CATCH_ENTRY_L0(__func__, EXIT_FAILURE);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,13 +323,17 @@ namespace
|
|||
|
||||
~stratum_protocol_handler_config()
|
||||
{
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
LOG_PRINT_L4("stratum_protocol_handler_config::dtor()");
|
||||
|
||||
|
||||
m_stop_flag = true;
|
||||
m_blocktemplate_update_thread.join();
|
||||
|
||||
if (m_p_core)
|
||||
m_p_core->remove_blockchain_update_listener(this);
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
void add_protocol_handler(protocol_handler_t* p_ph)
|
||||
|
|
@ -797,13 +801,18 @@ namespace
|
|||
|
||||
~stratum_protocol_handler()
|
||||
{
|
||||
if (m_connection_initialized)
|
||||
{
|
||||
m_config.remove_protocol_handler(this);
|
||||
m_connection_initialized = false;
|
||||
}
|
||||
NESTED_TRY_ENTRY();
|
||||
|
||||
LOG_PRINT_CC(m_context, "stratum_protocol_handler::dtor()", LOG_LEVEL_4);
|
||||
if (m_connection_initialized)
|
||||
{
|
||||
m_config.remove_protocol_handler(this);
|
||||
m_connection_initialized = false;
|
||||
}
|
||||
|
||||
LOG_PRINT_CC(
|
||||
m_context, "stratum_protocol_handler::dtor()", LOG_LEVEL_4);
|
||||
|
||||
NESTED_CATCH_ENTRY(__func__);
|
||||
}
|
||||
|
||||
// required member for epee::net_utils::boosted_tcp_server concept
|
||||
|
|
@ -1085,7 +1094,7 @@ struct stratum_server_impl
|
|||
};
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
stratum_server::stratum_server(core* c)
|
||||
: m_p_core(c)
|
||||
: m_p_core(c), m_threads_count{}
|
||||
{
|
||||
m_impl = new stratum_server_impl();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -2216,7 +2216,14 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig
|
|||
|
||||
// calculate key images for each change output
|
||||
crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);
|
||||
crypto::generate_key_derivation(m_account.get_keys().m_account_address.m_view_public_key, ft.one_time_key, derivation);
|
||||
CHECK_AND_ASSERT_THROW_MES(
|
||||
crypto::generate_key_derivation(
|
||||
m_account.get_keys().m_account_address.m_view_public_key,
|
||||
ft.one_time_key,
|
||||
derivation),
|
||||
"internal error: sign_transfer: failed to generate key derivation("
|
||||
<< m_account.get_keys().m_account_address.m_view_public_key
|
||||
<< ", view secret key: " << ft.one_time_key << ")");
|
||||
|
||||
for (size_t i = 0; i < ft.tx.vout.size(); ++i)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue