diff options
Diffstat (limited to 'contrib/epee/include')
-rw-r--r-- | contrib/epee/include/net/abstract_http_client.h | 1 | ||||
-rw-r--r-- | contrib/epee/include/net/abstract_tcp_server2.inl | 5 | ||||
-rw-r--r-- | contrib/epee/include/net/levin_protocol_handler_async.h | 88 | ||||
-rw-r--r-- | contrib/epee/include/storages/http_abstract_invoke.h | 20 | ||||
-rw-r--r-- | contrib/epee/include/string_coding.h | 2 |
5 files changed, 9 insertions, 107 deletions
diff --git a/contrib/epee/include/net/abstract_http_client.h b/contrib/epee/include/net/abstract_http_client.h index 46b3747cd..29a7ce19b 100644 --- a/contrib/epee/include/net/abstract_http_client.h +++ b/contrib/epee/include/net/abstract_http_client.h @@ -54,7 +54,6 @@ namespace net_utils std::string convert(char val); std::string conver_to_url_format(const std::string& uri); std::string convert_from_url_format(const std::string& uri); - std::string convert_to_url_format_force_all(const std::string& uri); namespace http { diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index 81aa725d1..d88f18194 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -583,11 +583,8 @@ namespace net_utils break; } } - else if (ec.value()) - terminate(); else { - cancel_timer(); - on_interrupted(); + terminate(); } }; m_strand.post( diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h index bd6ffe930..5122f1677 100644 --- a/contrib/epee/include/net/levin_protocol_handler_async.h +++ b/contrib/epee/include/net/levin_protocol_handler_async.h @@ -102,7 +102,6 @@ public: uint64_t m_max_packet_size; uint64_t m_invoke_timeout; - int invoke(int command, message_writer in_msg, std::string& buff_out, boost::uuids::uuid connection_id); template<class callback_t> int invoke_async(int command, message_writer in_msg, boost::uuids::uuid connection_id, const callback_t &cb, size_t timeout = LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED); @@ -165,14 +164,6 @@ public: }; std::atomic<bool> m_protocol_released; - std::atomic<bool> m_invoke_buf_ready; - - volatile int m_invoke_result_code; - - critical_section m_local_inv_buff_lock; - std::string m_local_inv_buff; - - critical_section m_call_lock; std::atomic<uint32_t> m_wait_count; std::atomic<uint32_t> m_close_called; @@ -318,8 +309,6 @@ public: m_wait_count = 0; m_oponent_protocol_ver = 0; m_connection_initialized = false; - m_invoke_buf_ready = false; - m_invoke_result_code = LEVIN_ERROR_CONNECTION; } virtual ~async_protocol_handler() { @@ -521,21 +510,8 @@ public: } else { - invoke_response_handlers_guard.unlock(); - //use sync call scenario - if(!m_wait_count && !m_close_called) - { - MERROR(m_connection_context << "no active invoke when response came, wtf?"); - return false; - }else - { - CRITICAL_REGION_BEGIN(m_local_inv_buff_lock); - m_local_inv_buff = std::string((const char*)buff_to_invoke.data(), buff_to_invoke.size()); - buff_to_invoke = epee::span<const uint8_t>((const uint8_t*)NULL, 0); - m_invoke_result_code = m_current_head.m_return_code; - CRITICAL_REGION_END(); - m_invoke_buf_ready = true; - } + MERROR("Received levin response but have no invoke handlers"); + return false; } }else { @@ -639,9 +615,6 @@ public: int err_code = LEVIN_OK; do { - CRITICAL_REGION_LOCAL(m_call_lock); - - m_invoke_buf_ready = false; CRITICAL_REGION_BEGIN(m_invoke_response_handlers_lock); if (command == m_connection_context.handshake_command()) @@ -673,55 +646,6 @@ public: return true; } - int invoke(int command, message_writer in_msg, std::string& buff_out) - { - misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler( - boost::bind(&async_protocol_handler::finish_outer_call, this)); - - CRITICAL_REGION_LOCAL(m_call_lock); - - m_invoke_buf_ready = false; - - if (command == m_connection_context.handshake_command()) - m_max_packet_size = m_config.m_max_packet_size; - - if (!send_message(in_msg.finalize_invoke(command))) - { - LOG_ERROR_CC(m_connection_context, "Failed to send request"); - return LEVIN_ERROR_CONNECTION; - } - - uint64_t ticks_start = misc_utils::get_tick_count(); - size_t prev_size = 0; - - while(!m_invoke_buf_ready && !m_protocol_released) - { - if(m_cache_in_buffer.size() - prev_size >= MIN_BYTES_WANTED) - { - prev_size = m_cache_in_buffer.size(); - ticks_start = misc_utils::get_tick_count(); - } - if(misc_utils::get_tick_count() - ticks_start > m_config.m_invoke_timeout) - { - MWARNING(m_connection_context << "invoke timeout (" << m_config.m_invoke_timeout << "), closing connection "); - close(); - return LEVIN_ERROR_CONNECTION_TIMEDOUT; - } - if(!m_pservice_endpoint->call_run_once_service_io()) - return LEVIN_ERROR_CONNECTION_DESTROYED; - } - - if(m_protocol_released) - return LEVIN_ERROR_CONNECTION_DESTROYED; - - CRITICAL_REGION_BEGIN(m_local_inv_buff_lock); - buff_out.swap(m_local_inv_buff); - m_local_inv_buff.clear(); - CRITICAL_REGION_END(); - - return m_invoke_result_code; - } - /*! Sends `message` without adding a levin header. The message must have been created with `make_noise_notify`, `make_fragmented_notify`, or `message_writer::finalize_notify`. See additional instructions for @@ -827,14 +751,6 @@ int async_protocol_handler_config<t_connection_context>::find_and_lock_connectio return LEVIN_OK; } //------------------------------------------------------------------------------------------ -template<class t_connection_context> -int async_protocol_handler_config<t_connection_context>::invoke(int command, message_writer in_msg, std::string& buff_out, boost::uuids::uuid connection_id) -{ - async_protocol_handler<t_connection_context>* aph; - int r = find_and_lock_connection(connection_id, aph); - return LEVIN_OK == r ? aph->invoke(command, std::move(in_msg), buff_out) : r; -} -//------------------------------------------------------------------------------------------ template<class t_connection_context> template<class callback_t> int async_protocol_handler_config<t_connection_context>::invoke_async(int command, message_writer in_msg, boost::uuids::uuid connection_id, const callback_t &cb, size_t timeout) { diff --git a/contrib/epee/include/storages/http_abstract_invoke.h b/contrib/epee/include/storages/http_abstract_invoke.h index c615b20e6..aaeae292f 100644 --- a/contrib/epee/include/storages/http_abstract_invoke.h +++ b/contrib/epee/include/storages/http_abstract_invoke.h @@ -26,13 +26,10 @@ // #pragma once -#include <boost/utility/string_ref.hpp> -#include <chrono> -#include <string> -#include "byte_slice.h" -#include "portable_storage_template_helper.h" + #include "net/http_base.h" -#include "net/http_server_handlers_map2.h" +#include "net/jsonrpc_structs.h" +#include "portable_storage_template_helper.h" namespace epee { @@ -136,12 +133,5 @@ namespace epee epee::json_rpc::error error_struct; return invoke_http_json_rpc(uri, method_name, out_struct, result_struct, error_struct, transport, timeout, http_method, req_id); } - - template<class t_command, class t_transport> - bool invoke_http_json_rpc(const boost::string_ref uri, typename t_command::request& out_struct, typename t_command::response& result_struct, t_transport& transport, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "POST", const std::string& req_id = "0") - { - return invoke_http_json_rpc(uri, t_command::methodname(), out_struct, result_struct, transport, timeout, http_method, req_id); - } - - } -} + } // namespace net_utils +} // namespace epee diff --git a/contrib/epee/include/string_coding.h b/contrib/epee/include/string_coding.h index 0d9c6c244..1e9da6fb2 100644 --- a/contrib/epee/include/string_coding.h +++ b/contrib/epee/include/string_coding.h @@ -35,7 +35,7 @@ namespace epee namespace string_encoding { inline - std::string& base64_chars() + const std::string& base64_chars() { static std::string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |