aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/misc_log_ex.h3
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.h4
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.inl33
-rw-r--r--contrib/epee/include/net/http_base.h3
-rw-r--r--contrib/epee/include/serialization/keyvalue_serialization_overloads.h36
-rw-r--r--contrib/epee/src/mlog.cpp4
6 files changed, 57 insertions, 26 deletions
diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h
index ec4bcbe2d..d351b024d 100644
--- a/contrib/epee/include/misc_log_ex.h
+++ b/contrib/epee/include/misc_log_ex.h
@@ -52,6 +52,7 @@
#include "easylogging++.h"
#define MONERO_DEFAULT_LOG_CATEGORY "default"
+#define MAX_LOG_FILE_SIZE 104850000 // 100 MB - 7600 bytes
#define MCFATAL(cat,x) CLOG(FATAL,cat) << x
#define MCERROR(cat,x) CLOG(ERROR,cat) << x
@@ -123,7 +124,7 @@
#endif
std::string mlog_get_default_log_path(const char *default_filename);
-void mlog_configure(const std::string &filename_base, bool console);
+void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size = MAX_LOG_FILE_SIZE);
void mlog_set_categories(const char *categories);
void mlog_set_log_level(int level);
void mlog_set_log(const char *log);
diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h
index ca58d5467..03f143fe4 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.h
+++ b/contrib/epee/include/net/abstract_tcp_server2.h
@@ -281,8 +281,6 @@ namespace net_utils
bool is_thread_worker();
- bool cleanup_connections();
-
/// The io_service used to perform asynchronous operations.
std::unique_ptr<boost::asio::io_service> m_io_service_local_instance;
boost::asio::io_service& io_service_;
@@ -309,7 +307,7 @@ namespace net_utils
connection_ptr new_connection_;
boost::mutex connections_mutex;
- std::deque<std::pair<boost::system_time, connection_ptr>> connections_;
+ std::set<connection_ptr> connections_;
}; // class <>boosted_tcp_server
diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl
index 61276e761..76988a26e 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.inl
+++ b/contrib/epee/include/net/abstract_tcp_server2.inl
@@ -54,8 +54,6 @@
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
-#define CONNECTION_CLEANUP_TIME 30 // seconds
-
PRAGMA_WARNING_PUSH
namespace epee
{
@@ -808,7 +806,6 @@ POP_WARNINGS
m_threads_count = threads_count;
m_main_thread_id = boost::this_thread::get_id();
MLOG_SET_THREAD_NAME("[SRV_MAIN]");
- add_idle_handler(boost::bind(&boosted_tcp_server::cleanup_connections, this), 5000);
while(!m_stop_signal_sent)
{
@@ -898,7 +895,7 @@ POP_WARNINGS
connections_mutex.lock();
for (auto &c: connections_)
{
- c.second->cancel();
+ c->cancel();
}
connections_.clear();
connections_mutex.unlock();
@@ -907,19 +904,6 @@ POP_WARNINGS
}
//---------------------------------------------------------------------------------
template<class t_protocol_handler>
- bool boosted_tcp_server<t_protocol_handler>::cleanup_connections()
- {
- connections_mutex.lock();
- boost::system_time cutoff = boost::get_system_time() - boost::posix_time::seconds(CONNECTION_CLEANUP_TIME);
- while (!connections_.empty() && connections_.front().first < cutoff)
- {
- connections_.pop_front();
- }
- connections_mutex.unlock();
- return true;
- }
- //---------------------------------------------------------------------------------
- template<class t_protocol_handler>
bool boosted_tcp_server<t_protocol_handler>::is_stop_signal_sent()
{
return m_stop_signal_sent;
@@ -958,9 +942,10 @@ POP_WARNINGS
connection_ptr new_connection_l(new connection<t_protocol_handler>(io_service_, m_config, m_sock_count, m_sock_number, m_pfilter, m_connection_type) );
connections_mutex.lock();
- connections_.push_back(std::make_pair(boost::get_system_time(), new_connection_l));
+ connections_.insert(new_connection_l);
MDEBUG("connections_ size now " << connections_.size());
connections_mutex.unlock();
+ epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){ CRITICAL_REGION_LOCAL(connections_mutex); connections_.erase(new_connection_l); });
boost::asio::ip::tcp::socket& sock_ = new_connection_l->socket();
//////////////////////////////////////////////////////////////////////////
@@ -1038,6 +1023,10 @@ POP_WARNINGS
_dbg3("Connected success to " << adr << ':' << port);
+ // start adds the connection to the config object's list, so we don't need to have it locally anymore
+ connections_mutex.lock();
+ connections_.erase(new_connection_l);
+ connections_mutex.unlock();
bool r = new_connection_l->start(false, 1 < m_threads_count);
if (r)
{
@@ -1062,9 +1051,10 @@ POP_WARNINGS
TRY_ENTRY();
connection_ptr new_connection_l(new connection<t_protocol_handler>(io_service_, m_config, m_sock_count, m_sock_number, m_pfilter, m_connection_type) );
connections_mutex.lock();
- connections_.push_back(std::make_pair(boost::get_system_time(), new_connection_l));
+ connections_.insert(new_connection_l);
MDEBUG("connections_ size now " << connections_.size());
connections_mutex.unlock();
+ epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){ CRITICAL_REGION_LOCAL(connections_mutex); connections_.erase(new_connection_l); });
boost::asio::ip::tcp::socket& sock_ = new_connection_l->socket();
//////////////////////////////////////////////////////////////////////////
@@ -1113,6 +1103,11 @@ POP_WARNINGS
{
_dbg3("[sock " << new_connection_l->socket().native_handle() << "] Connected success to " << adr << ':' << port <<
" from " << lep.address().to_string() << ':' << lep.port());
+
+ // start adds the connection to the config object's list, so we don't need to have it locally anymore
+ connections_mutex.lock();
+ connections_.erase(new_connection_l);
+ connections_mutex.unlock();
bool r = new_connection_l->start(false, 1 < m_threads_count);
if (r)
{
diff --git a/contrib/epee/include/net/http_base.h b/contrib/epee/include/net/http_base.h
index e5aa06cb4..144acad9d 100644
--- a/contrib/epee/include/net/http_base.h
+++ b/contrib/epee/include/net/http_base.h
@@ -155,7 +155,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(0)
{}
http_method m_http_method;
diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
index 1a58cab99..4423f2608 100644
--- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
+++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
@@ -227,6 +227,18 @@ namespace epee
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
+ static bool kv_serialize(const std::deque<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
+ {
+ return serialize_stl_container_t_val(d, stg, hparent_section, pname);
+ }
+ //-------------------------------------------------------------------------------------------------------------------
+ template<class t_type, class t_storage>
+ static bool kv_unserialize(std::deque<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
+ {
+ return unserialize_stl_container_t_val(d, stg, hparent_section, pname);
+ }
+ //-------------------------------------------------------------------------------------------------------------------
+ template<class t_type, class t_storage>
static bool kv_serialize(const std::list<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
return serialize_stl_container_t_val(d, stg, hparent_section, pname);
@@ -268,6 +280,18 @@ namespace epee
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
+ static bool kv_serialize(const std::deque<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
+ {
+ return serialize_stl_container_t_obj(d, stg, hparent_section, pname);
+ }
+ //-------------------------------------------------------------------------------------------------------------------
+ template<class t_type, class t_storage>
+ static bool kv_unserialize(std::deque<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
+ {
+ return unserialize_stl_container_t_obj(d, stg, hparent_section, pname);
+ }
+ //-------------------------------------------------------------------------------------------------------------------
+ template<class t_type, class t_storage>
static bool kv_serialize(const std::list<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
return serialize_stl_container_t_obj(d, stg, hparent_section, pname);
@@ -353,6 +377,18 @@ namespace epee
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
+ bool kv_serialize(const std::deque<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
+ {
+ 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_serialize(d, stg, hparent_section, pname);
+ }
+ //-------------------------------------------------------------------------------------------------------------------
+ template<class t_type, class t_storage>
+ bool kv_unserialize(std::deque<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
+ {
+ 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);
+ }
+ //-------------------------------------------------------------------------------------------------------------------
+ template<class t_type, class t_storage>
bool kv_serialize(const std::list<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
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_serialize(d, stg, hparent_section, pname);
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp
index a3f38e677..964ba41df 100644
--- a/contrib/epee/src/mlog.cpp
+++ b/contrib/epee/src/mlog.cpp
@@ -111,7 +111,7 @@ static const char *get_default_categories(int level)
return categories;
}
-void mlog_configure(const std::string &filename_base, bool console)
+void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size)
{
el::Configurations c;
c.setGlobally(el::ConfigurationType::Filename, filename_base);
@@ -121,7 +121,7 @@ void mlog_configure(const std::string &filename_base, bool console)
log_format = MLOG_BASE_FORMAT;
c.setGlobally(el::ConfigurationType::Format, log_format);
c.setGlobally(el::ConfigurationType::ToStandardOutput, console ? "true" : "false");
- c.setGlobally(el::ConfigurationType::MaxLogFileSize, "104850000"); // 100 MB - 7600 bytes
+ c.setGlobally(el::ConfigurationType::MaxLogFileSize, std::to_string(max_log_file_size));
el::Loggers::setDefaultConfigurations(c, true);
el::Loggers::addFlag(el::LoggingFlag::HierarchicalLogging);