Skip to content

Commit 2691d10

Browse files
leecoderjellevdd
authored andcommitted
Async thr wait in basic_client_facade dtor
1 parent 722b012 commit 2691d10

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

boost/network/protocol/http/client/async_impl.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ struct async_client
6363

6464
~async_client() throw() {
6565
sentinel_.reset();
66+
}
67+
68+
void wait_complete() {
69+
sentinel_.reset();
6670
if (lifetime_thread_.get()) {
67-
if (lifetime_thread_->get_id() != boost::this_thread::get_id()) {
68-
lifetime_thread_->join();
69-
}
71+
lifetime_thread_->join();
7072
lifetime_thread_.reset();
7173
}
7274
}

boost/network/protocol/http/client/facade.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ struct basic_client_facade {
3737
init_pimpl(options);
3838
}
3939

40+
virtual ~basic_client_facade() {
41+
pimpl->wait_complete();
42+
}
43+
4044
response head(request const& request) {
4145
return pimpl->request_skeleton(request,
4246
"HEAD",

boost/network/protocol/http/client/sync_impl.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ struct sync_client
7373
service_ptr.reset();
7474
}
7575

76+
void wait_complete() {}
77+
7678
basic_response<Tag> request_skeleton(basic_request<Tag> const& request_,
7779
string_type method, bool get_body,
7880
body_callback_function_type callback,

libs/network/test/http/client_get_test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,15 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(https_client_get_test, client, client_types) {
3636
}
3737

3838
#endif
39+
40+
BOOST_AUTO_TEST_CASE_TEMPLATE(http_temp_client_get_test, client, client_types) {
41+
typename client::request request("http://www.google.co.kr");
42+
typename client::response response;
43+
BOOST_REQUIRE_NO_THROW ( response = client().get(request) );
44+
typename net::headers_range<typename client::response>::type range = headers(response)["Content-Type"];
45+
BOOST_CHECK ( !boost::empty(range) );
46+
BOOST_REQUIRE_NO_THROW ( BOOST_CHECK ( body(response).size() != 0 ) );
47+
BOOST_CHECK_EQUAL ( response.version().substr(0,7), std::string("HTTP/1.") );
48+
BOOST_CHECK_EQUAL ( response.status(), 200u );
49+
BOOST_CHECK_EQUAL ( response.status_message(), std::string("OK") );
50+
}

0 commit comments

Comments
 (0)