aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/misc_log_ex.h11
-rw-r--r--contrib/epee/include/misc_os_dependent.h12
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.inl32
-rw-r--r--contrib/epee/include/net/http_server_handlers_map2.h6
-rw-r--r--contrib/epee/include/net/net_utils_base.h2
-rw-r--r--contrib/epee/include/storages/portable_storage_from_bin.h2
-rw-r--r--contrib/epee/include/string_tools.h4
7 files changed, 50 insertions, 19 deletions
diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h
index d1451ff12..82760dfff 100644
--- a/contrib/epee/include/misc_log_ex.h
+++ b/contrib/epee/include/misc_log_ex.h
@@ -424,6 +424,7 @@ namespace log_space
}
std::cout << buf;
+ std::cout << std::flush;
#endif
reset_console_color();
return true;
@@ -1440,8 +1441,16 @@ POP_WARNINGS
#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_NO_ASSERT_MES_L
+#define CHECK_AND_NO_ASSERT_MES_L(expr, fail_ret_val, l, message) do{if(!(expr)) {LOG_PRINT_L##l(message); /*LOCAL_ASSERT(expr);*/ return fail_ret_val;};}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_L0(message); /*LOCAL_ASSERT(expr);*/ return fail_ret_val;};}while(0)
+#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message) CHECK_AND_NO_ASSERT_MES_L(expr, fail_ret_val, 0, message)
+#endif
+
+#ifndef CHECK_AND_NO_ASSERT_MES_L1
+#define CHECK_AND_NO_ASSERT_MES_L1(expr, fail_ret_val, message) CHECK_AND_NO_ASSERT_MES_L(expr, fail_ret_val, 1, message)
#endif
diff --git a/contrib/epee/include/misc_os_dependent.h b/contrib/epee/include/misc_os_dependent.h
index 2abca0446..806d3e83e 100644
--- a/contrib/epee/include/misc_os_dependent.h
+++ b/contrib/epee/include/misc_os_dependent.h
@@ -53,11 +53,13 @@ namespace misc_utils
#if defined(_MSC_VER)
return ::GetTickCount64();
#elif defined(WIN32)
-# if defined(WIN64)
- return GetTickCount64();
-# else
- return GetTickCount();
-# endif
+ static LARGE_INTEGER pcfreq = {0};
+ LARGE_INTEGER ticks;
+ if (!pcfreq.QuadPart)
+ QueryPerformanceFrequency(&pcfreq);
+ QueryPerformanceCounter(&ticks);
+ ticks.QuadPart *= 1000; /* we want msec */
+ return ticks.QuadPart / pcfreq.QuadPart;
#elif defined(__MACH__)
clock_serv_t cclock;
mach_timespec_t mts;
diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl
index 1c854dfb7..94dbe7458 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.inl
+++ b/contrib/epee/include/net/abstract_tcp_server2.inl
@@ -88,7 +88,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
PRAGMA_WARNING_DISABLE_VS(4355)
//---------------------------------------------------------------------------------
template<class t_protocol_handler>
- connection<t_protocol_handler>::~connection()
+ connection<t_protocol_handler>::~connection() noexcept(false)
{
if(!m_was_shutdown)
{
@@ -252,11 +252,24 @@ PRAGMA_WARNING_DISABLE_VS(4355)
template<class t_protocol_handler>
void connection<t_protocol_handler>::save_dbg_log()
{
+ std::string address, port;
+ boost::system::error_code e;
+
+ boost::asio::ip::tcp::endpoint endpoint = socket_.remote_endpoint(e);
+ if (e)
+ {
+ address = "<not connected>";
+ port = "<not connected>";
+ }
+ else
+ {
+ address = endpoint.address().to_string();
+ port = boost::lexical_cast<std::string>(endpoint.port());
+ }
_mark_c("net/kind" ,
- " connection type " << to_string( m_connection_type ) << " "
- << socket_.local_endpoint().address().to_string() << ":" << socket_.local_endpoint().port()
- << " <--> " << socket_.remote_endpoint().address().to_string() << ":" << socket_.remote_endpoint().port()
- );
+ " connection type " << to_string( m_connection_type ) << " "
+ << socket_.local_endpoint().address().to_string() << ":" << socket_.local_endpoint().port()
+ << " <--> " << address << ":" << port);
}
//---------------------------------------------------------------------------------
template<class t_protocol_handler>
@@ -477,7 +490,9 @@ PRAGMA_WARNING_DISABLE_VS(4355)
sleep_before_packet(cb, 1, 1);
}
- epee::critical_region_t<decltype(m_send_que_lock)> send_guard(m_send_que_lock); // *** critical ***
+ m_send_que_lock.lock(); // *** critical ***
+ epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){m_send_que_lock.unlock();});
+
long int retry=0;
const long int retry_limit = 5*4;
while (m_send_que.size() > ABSTRACT_SERVER_SEND_QUE_MAX_COUNT)
@@ -491,14 +506,15 @@ PRAGMA_WARNING_DISABLE_VS(4355)
long int ms = 250 + (rand()%50);
_info_c("net/sleep", "Sleeping because QUEUE is FULL, in " << __FUNCTION__ << " for " << ms << " ms before packet_size="<<cb); // XXX debug sleep
+ m_send_que_lock.unlock();
boost::this_thread::sleep(boost::posix_time::milliseconds( ms ) );
+ m_send_que_lock.lock();
_dbg1("sleep for queue: " << ms);
if (retry > retry_limit) {
- send_guard.unlock();
_erro("send que size is more than ABSTRACT_SERVER_SEND_QUE_MAX_COUNT(" << ABSTRACT_SERVER_SEND_QUE_MAX_COUNT << "), shutting down connection");
// _dbg1_c("net/sleep", "send que size is more than ABSTRACT_SERVER_SEND_QUE_MAX_COUNT(" << ABSTRACT_SERVER_SEND_QUE_MAX_COUNT << "), shutting down connection");
- close();
+ shutdown();
return false;
}
}
diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h
index a822cce3e..3a7d5333b 100644
--- a/contrib/epee/include/net/http_server_handlers_map2.h
+++ b/contrib/epee/include/net/http_server_handlers_map2.h
@@ -168,8 +168,8 @@
response_info.m_header_info.m_content_type = " application/json"; \
LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2);
-#define MAP_JON_RPC_WE(method_name, callback_f, command_type) \
- else if(callback_name == method_name) \
+#define MAP_JON_RPC_WE_IF(method_name, callback_f, command_type, cond) \
+ else if((callback_name == method_name) && (cond)) \
{ \
PREPARE_OBJECTS_FROM_JSON(command_type) \
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
@@ -184,6 +184,8 @@
return true;\
}
+#define MAP_JON_RPC_WE(method_name, callback_f, command_type) MAP_JON_RPC_WE_IF(method_name, callback_f, command_type, true)
+
#define MAP_JON_RPC_WERI(method_name, callback_f, command_type) \
else if(callback_name == method_name) \
{ \
diff --git a/contrib/epee/include/net/net_utils_base.h b/contrib/epee/include/net/net_utils_base.h
index f963e7746..78e555fac 100644
--- a/contrib/epee/include/net/net_utils_base.h
+++ b/contrib/epee/include/net/net_utils_base.h
@@ -119,7 +119,7 @@ namespace net_utils
virtual bool add_ref()=0;
virtual bool release()=0;
protected:
- virtual ~i_service_endpoint(){}
+ virtual ~i_service_endpoint() noexcept(false) {}
};
diff --git a/contrib/epee/include/storages/portable_storage_from_bin.h b/contrib/epee/include/storages/portable_storage_from_bin.h
index bc2fb1463..44a80cb21 100644
--- a/contrib/epee/include/storages/portable_storage_from_bin.h
+++ b/contrib/epee/include/storages/portable_storage_from_bin.h
@@ -68,7 +68,7 @@ namespace epee
++m_counter_ref;
CHECK_AND_ASSERT_THROW_MES(m_counter_ref < EPEE_PORTABLE_STORAGE_RECURSION_LIMIT_INTERNAL, "Wrong blob data in portable storage: recursion limitation (" << EPEE_PORTABLE_STORAGE_RECURSION_LIMIT_INTERNAL << ") exceeded");
}
- ~recursuion_limitation_guard()
+ ~recursuion_limitation_guard() noexcept(false)
{
CHECK_AND_ASSERT_THROW_MES(m_counter_ref != 0, "Internal error: m_counter_ref == 0 while ~recursuion_limitation_guard()");
--m_counter_ref;
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h
index 8289ee0ba..b973c6d48 100644
--- a/contrib/epee/include/string_tools.h
+++ b/contrib/epee/include/string_tools.h
@@ -139,9 +139,11 @@ namespace string_tools
}
//----------------------------------------------------------------------------
template<class CharT>
- bool parse_hexstr_to_binbuff(const std::basic_string<CharT>& s, std::basic_string<CharT>& res)
+ bool parse_hexstr_to_binbuff(const std::basic_string<CharT>& s, std::basic_string<CharT>& res, bool allow_partial_byte = false)
{
res.clear();
+ if (!allow_partial_byte && (s.size() & 1))
+ return false;
try
{
long v = 0;