Skip to content

Commit 1611feb

Browse files
author
Valtteri Heikkila
committed
Added missing error in linux_connection cancel() and moved pool timer canceling out from close() in http_linux.cpp
1 parent bbc9378 commit 1611feb

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

Release/src/http/client/http_linux.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,24 @@ namespace web { namespace http
6565
m_keep_alive(true)
6666
{}
6767

68-
bool close(bool cancel_timer)
68+
void close()
6969
{
70-
if (cancel_timer)
71-
{
72-
m_pool_timer.cancel();
73-
}
7470
m_keep_alive = false;
7571
boost::system::error_code error;
7672
m_socket.shutdown(tcp::socket::shutdown_both, error);
7773
m_socket.close(error);
78-
return !error;
7974
}
8075

81-
bool cancel()
76+
boost::system::error_code cancel()
8277
{
8378
boost::system::error_code error;
8479
m_socket.cancel(error);
85-
return !error;
80+
return error;
81+
}
82+
83+
void cancel_pool_timer()
84+
{
85+
m_pool_timer.cancel();
8686
}
8787

8888
bool is_reused() const { return m_is_reused; }
@@ -102,7 +102,7 @@ namespace web { namespace http
102102

103103
void start_reuse()
104104
{
105-
m_pool_timer.cancel();
105+
cancel_pool_timer();
106106
m_is_reused = true;
107107
}
108108

@@ -131,7 +131,8 @@ namespace web { namespace http
131131
// it only has shared_ptr reference to pool. Connections use weak_ptr instead.
132132
for (auto& connection : m_connections)
133133
{
134-
connection->close(true);
134+
connection->cancel_pool_timer();
135+
connection->close();
135136
}
136137
}
137138

@@ -151,7 +152,7 @@ namespace web { namespace http
151152
else
152153
{
153154
// Connection is not returned to pool => will be destroyed.
154-
connection->close(false);
155+
connection->close();
155156
}
156157
}
157158

@@ -274,9 +275,10 @@ namespace web { namespace http
274275
if (!ec)
275276
{
276277
m_timedout = true;
277-
if (!m_connection->cancel())
278+
auto error(m_connection->cancel());
279+
if (error)
278280
{
279-
report_error("Failed to cancel the socket", boost::system::error_code());
281+
report_error("Failed to cancel the socket", error);
280282
}
281283
}
282284
}
@@ -419,7 +421,7 @@ namespace web { namespace http
419421
// Cancel operations and all async handlers.
420422
ctx->m_connection->cancel();
421423
// Shut down transmissions and close socket. Also prevents connection being pooled.
422-
ctx->m_connection->close(false);
424+
ctx->m_connection->close();
423425
});
424426
}
425427
}
@@ -499,7 +501,7 @@ namespace web { namespace http
499501
{
500502
ctx->m_timeout_timer.cancel();
501503

502-
ctx->m_connection->close(false);
504+
ctx->m_connection->close();
503505
ctx->m_connection = m_pool->obtain();
504506

505507
auto endpoint = *endpoints;
@@ -754,7 +756,7 @@ namespace web { namespace http
754756
{
755757
// Connection was closed while connection was in pool.
756758
// Ensure connection is closed in a robust way.
757-
ctx->m_connection->close(false);
759+
ctx->m_connection->close();
758760

759761
// Replace context and destroy the old one. The request,
760762
// completion event and cancellation registration are copied to

0 commit comments

Comments
 (0)