aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/include/console_handler.h30
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.inl4
-rw-r--r--contrib/epee/include/net/http_server_handlers_map2.h6
3 files changed, 26 insertions, 14 deletions
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h
index 0eff095e1..c6e7c857d 100644
--- a/contrib/epee/include/console_handler.h
+++ b/contrib/epee/include/console_handler.h
@@ -251,27 +251,33 @@ namespace epee
m_stdin_reader.stop();
}
+ void print_prompt()
+ {
+ if (!m_prompt.empty())
+ {
+ epee::log_space::set_console_color(epee::log_space::console_color_yellow, true);
+ std::cout << m_prompt;
+ if (' ' != m_prompt.back())
+ std::cout << ' ';
+ epee::log_space::reset_console_color();
+ std::cout.flush();
+ }
+ }
+
private:
template<typename t_cmd_handler>
bool run(const std::string& prompt, const std::string& usage, const t_cmd_handler& cmd_handler, std::function<void(void)> exit_handler)
{
TRY_ENTRY();
bool continue_handle = true;
+ m_prompt = prompt;
while(continue_handle)
{
if (!m_running)
{
break;
}
- if (!prompt.empty())
- {
- epee::log_space::set_console_color(epee::log_space::console_color_yellow, true);
- std::cout << prompt;
- if (' ' != prompt.back())
- std::cout << ' ';
- epee::log_space::reset_console_color();
- std::cout.flush();
- }
+ print_prompt();
std::string command;
bool get_line_ret = m_stdin_reader.get_line(command);
@@ -313,6 +319,7 @@ namespace epee
private:
async_stdin_reader m_stdin_reader;
std::atomic<bool> m_running = {true};
+ std::string m_prompt;
};
@@ -447,6 +454,11 @@ namespace epee
{
return m_console_handler.run(boost::bind(&console_handlers_binder::process_command_str, this, _1), prompt, usage_string, exit_handler);
}
+
+ void print_prompt()
+ {
+ m_console_handler.print_prompt();
+ }
};
///* work around because of broken boost bind */
diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl
index 612e2b417..b75a9ecaa 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.inl
+++ b/contrib/epee/include/net/abstract_tcp_server2.inl
@@ -899,9 +899,7 @@ POP_WARNINGS
boost::bind(&boosted_tcp_server<t_protocol_handler>::handle_accept, this,
boost::asio::placeholders::error));
- bool r = conn->start(true, 1 < m_threads_count);
- if (!r)
- _erro("[sock " << conn->socket().native_handle() << "] Failed to start connection, connections_count = " << m_sock_count);
+ conn->start(true, 1 < m_threads_count);
conn->save_dbg_log();
}else
{
diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h
index f812077f1..a822cce3e 100644
--- a/contrib/epee/include/net/http_server_handlers_map2.h
+++ b/contrib/epee/include/net/http_server_handlers_map2.h
@@ -55,8 +55,8 @@
#define MAP_URI_AUTO_XML2(s_pattern, callback_f, command_type) //TODO: don't think i ever again will use xml - ambiguous and "overtagged" format
-#define MAP_URI_AUTO_JON2(s_pattern, callback_f, command_type) \
- else if(query_info.m_URI == s_pattern) \
+#define MAP_URI_AUTO_JON2_IF(s_pattern, callback_f, command_type, cond) \
+ else if((query_info.m_URI == s_pattern) && (cond)) \
{ \
handled = true; \
uint64_t ticks = misc_utils::get_tick_count(); \
@@ -80,6 +80,8 @@
LOG_PRINT( s_pattern << " processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
}
+#define MAP_URI_AUTO_JON2(s_pattern, callback_f, command_type) MAP_URI_AUTO_JON2_IF(s_pattern, callback_f, command_type, true)
+
#define MAP_URI_AUTO_BIN2(s_pattern, callback_f, command_type) \
else if(query_info.m_URI == s_pattern) \
{ \