From 43962f41031d85778e4ae5949ec1a6141a1bcac2 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 27 Mar 2016 12:53:20 +0100 Subject: abstract_tcp_server2: possible fix for exception in handle_accept --- contrib/epee/include/net/abstract_tcp_server2.inl | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'contrib/epee') diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index 1c854dfb7..b3d4e5fdb 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -252,11 +252,24 @@ PRAGMA_WARNING_DISABLE_VS(4355) template void connection::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 = ""; + port = ""; + } + else + { + address = endpoint.address().to_string(); + port = boost::lexical_cast(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 -- cgit v1.2.3 From b1aaf20e5759be6283ed13c19f91f658705bc009 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 2 Apr 2016 20:59:24 +0100 Subject: epee: flush output after a message This is equivalent to line buffering, as C++ seems to lack a setvbuf equivalent which alows line buffering. --- contrib/epee/include/misc_log_ex.h | 1 + 1 file changed, 1 insertion(+) (limited to 'contrib/epee') diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index d1451ff12..7cb1e61aa 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; -- cgit v1.2.3 From aaaf9e2e6d81a2f300d724f1daab3d7aa1f798bf Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 6 Apr 2016 03:41:52 +0100 Subject: Fix get_tick_count() on Windows GetTickCount used in 52056dcfc480a126e06afaf209b1772b6aa77fb3 only has ~10-16ms resolution. Use higher rez timer to get 1ms rez. --- contrib/epee/include/misc_os_dependent.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'contrib/epee') 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; -- cgit v1.2.3