Skip to content
Snippets Groups Projects
Commit 500ae6ef authored by Seva's avatar Seva
Browse files

http: handle asio cancel delays

parent b01d3cfc
No related branches found
No related tags found
No related merge requests found
...@@ -294,6 +294,7 @@ private: ...@@ -294,6 +294,7 @@ private:
Response response_ {}; Response response_ {};
std::string request_; std::string request_;
std::atomic<bool> message_complete_ {false}; std::atomic<bool> message_complete_ {false};
std::atomic<bool> finishing_ {false};
std::unique_ptr<http_parser> parser_; std::unique_ptr<http_parser> parser_;
std::unique_ptr<http_parser_settings> parser_s_; std::unique_ptr<http_parser_settings> parser_s_;
......
...@@ -53,7 +53,6 @@ Connection::~Connection() ...@@ -53,7 +53,6 @@ Connection::~Connection()
if (is_open()){ if (is_open()){
#ifdef OPENDHT_PROXY_OPENSSL #ifdef OPENDHT_PROXY_OPENSSL
get_socket().cancel(); get_socket().cancel();
get_socket().shutdown(asio::ip::tcp::socket::shutdown_both);
#endif #endif
get_socket().close(); get_socket().close();
} }
...@@ -682,10 +681,15 @@ Request::post() ...@@ -682,10 +681,15 @@ Request::post()
void void
Request::terminate(const asio::error_code& ec) Request::terminate(const asio::error_code& ec)
{ {
if (finishing_.load())
return;
if (ec != asio::error::eof and ec != asio::error::operation_aborted) if (ec != asio::error::eof and ec != asio::error::operation_aborted)
if (logger_) if (logger_)
logger_->e("[http:request:%i] end with error: %s", id_, ec.message().c_str()); logger_->e("[http:request:%i] end with error: %s", id_, ec.message().c_str());
finishing_.store(true);
// close the connection cancelling the scheduled socket operations on the io_context // close the connection cancelling the scheduled socket operations on the io_context
conn_.reset(); conn_.reset();
// reset the http_parser holding the data pointer to the user callbacks // reset the http_parser holding the data pointer to the user callbacks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment