@@ -91,14 +91,14 @@ namespace web { namespace http
91
91
request_context::report_error (errorcodeValue, message);
92
92
}
93
93
94
- std::unique_ptr< tcp::socket> m_socket;
94
+ tcp::socket m_socket;
95
95
std::unique_ptr<boost::asio::ssl::stream<tcp::socket>> m_ssl_stream;
96
96
size_t m_known_size;
97
97
size_t m_current_size;
98
98
bool m_needChunked;
99
99
bool m_timedout;
100
100
boost::asio::streambuf m_body_buf;
101
- std::unique_ptr< boost::asio::deadline_timer> m_timer;
101
+ boost::asio::deadline_timer m_timer;
102
102
103
103
template <typename socket_type>
104
104
void shutdown_socket (socket_type &socket)
@@ -110,17 +110,9 @@ namespace web { namespace http
110
110
111
111
~linux_request_context ()
112
112
{
113
- if (m_timer)
114
- {
115
- m_timer->cancel ();
116
- m_timer.reset ();
117
- }
113
+ m_timer.cancel ();
118
114
119
- if (m_socket)
120
- {
121
- shutdown_socket (*m_socket);
122
- m_socket.reset ();
123
- }
115
+ shutdown_socket (m_socket);
124
116
125
117
if (m_ssl_stream)
126
118
{
@@ -144,11 +136,7 @@ namespace web { namespace http
144
136
}
145
137
else
146
138
{
147
- auto sock = m_socket.get ();
148
- if (sock != nullptr )
149
- {
150
- sock->cancel ();
151
- }
139
+ m_socket.cancel ();
152
140
}
153
141
}
154
142
}
@@ -160,6 +148,7 @@ namespace web { namespace http
160
148
, m_needChunked(false )
161
149
, m_timedout(false )
162
150
, m_current_size(0 )
151
+ , m_timer(crossplat::threadpool::shared_instance().service())
163
152
{
164
153
}
165
154
@@ -267,10 +256,9 @@ namespace web { namespace http
267
256
268
257
tcp::resolver::query query (host, utility::conversions::print_string (port));
269
258
270
- ctx->m_timer .reset (new boost::asio::deadline_timer (m_io_service));
271
259
const int secs = static_cast <int >(client_config ().timeout ().count ());
272
- ctx->m_timer -> expires_from_now (boost::posix_time::milliseconds (secs * 1000 ));
273
- ctx->m_timer -> async_wait (boost::bind (&linux_request_context::cancel, ctx.get (), boost::asio::placeholders::error));
260
+ ctx->m_timer . expires_from_now (boost::posix_time::milliseconds (secs * 1000 ));
261
+ ctx->m_timer . async_wait (boost::bind (&linux_request_context::cancel, ctx.get (), boost::asio::placeholders::error));
274
262
275
263
m_resolver.async_resolve (query, boost::bind (&linux_client::handle_resolve, this , boost::asio::placeholders::error, boost::asio::placeholders::iterator, ctx));
276
264
}
0 commit comments