Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

0.12-devel to be C++11-only#569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
36 commits
Select commitHold shift + click to select a range
a370594
Run clang-tidy with all checks.
deanberrisOct 28, 2015
44bd36b
Manual changes to update style and fix breakages
deanberrisOct 28, 2015
5f6e9ee
Changes to make things build
deanberrisOct 31, 2015
7b88a41
Reintroduce missing code for parsing query maps
deanberrisOct 31, 2015
6349c11
clang-tidy modernize-.* all the things
deanberrisNov 2, 2015
6d8879c
Upgrade travis config
deanberrisNov 2, 2015
65a0e6e
Fix typo in URL
deanberrisNov 2, 2015
feec209
Fix another typo on the URL.
deanberrisNov 2, 2015
4847865
Make travis wait for a Boost build to finish
deanberrisNov 2, 2015
e19af74
Change level of travis_wait call; chmod +x .sh files
deanberrisNov 2, 2015
abe68b4
Only support Boost 1.59 for now.
deanberrisNov 2, 2015
b10dfbb
Only produce shared+multithreaded debug & release boost libs
deanberrisNov 2, 2015
8cb4c16
Looks like we need static libs too
deanberrisNov 2, 2015
198dd07
Integrate travis; Use Boost 1.57 at least; Always use shared libs fro…
deanberrisNov 2, 2015
f6c7ee6
Use the dynamic version of Boost.Test always.
deanberrisNov 2, 2015
de7c710
Use v4 again instead of just address
deanberrisNov 4, 2015
39a2705
v4() for real this time
deanberrisNov 4, 2015
2e3340f
Change test to fetch different targets
deanberrisNov 12, 2015
7e0f93e
Simplify http test
deanberrisNov 12, 2015
552401b
Use ninja-build
deanberrisNov 12, 2015
19beafb
Update cmake
deanberrisNov 12, 2015
99f6168
Use updated cmake to support ninja-build
deanberrisNov 12, 2015
937d589
Travis cannot handle ninja builds yet, probably to lack of resources …
deanberrisNov 12, 2015
d5ec24e
j4 is too much. :(
deanberrisNov 12, 2015
d661fcc
Check with the sanitizers
deanberrisNov 12, 2015
5751338
Honor the CMAKE_CXX_FLAGS environment variable
deanberrisNov 12, 2015
511dd04
Print latest log properly
deanberrisNov 12, 2015
9fbc300
Fix some issues with the (deprecated) synchronous client implementati…
deanberrisNov 16, 2015
2f2239c
Only use libc++ if in OS X
deanberrisNov 16, 2015
4be4eae
Issue identified with memory sanitizer
deanberrisNov 16, 2015
600daff
Fix unsafe usage of boost::as_literal, caught by memory sanitiser
deanberrisNov 16, 2015
03870ca
Force use of size_t in distance calculation
deanberrisNov 16, 2015
9bad07c
Removing noexcept from defaulted move constructor
deanberrisNov 18, 2015
2f2c021
Track origins for memsan runs
deanberrisNov 18, 2015
7f70dac
Exclude msan builds from g++
deanberrisNov 18, 2015
8a8279a
Do not use msan yet; Boost seems to be not msan-clean
deanberrisNov 18, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Fix some issues with the (deprecated) synchronous client implementati…
…on running under tsan; also require C++11 in GNU compilers moving forward by default
  • Loading branch information
@deanberris
deanberris committedNov 16, 2015
commit9fbc3008679edf85bc866196e55fe2abf9580f43
14 changes: 5 additions & 9 deletionsCMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -71,16 +71,12 @@ if (OPENSSL_FOUND)
endif()

if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# Use C++11 when using GNU compilers.
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# We want to link in C++11 mode if we're using Clang and on OS X.
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ftemplate-depth=256 -std=c++11 -stdlib=libc++")
else()
# We just add the -Wall and a high enough template depth
# flag for Clang in other systems.
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ftemplate-depth=256")
endif()
# We want to link in C++11 mode in Clang too, but also set a high enough
# template depth for the template metaprogramming.
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ftemplate-depth=256 -std=c++11 -stdlib=libc++")
endif()


Expand Down
19 changes: 12 additions & 7 deletionsboost/network/protocol/http/client/connection/sync_normal.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt)

#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/network/protocol/http/algorithms/linearize.hpp>
#include <boost/network/protocol/http/response.hpp>
#include <boost/network/protocol/http/traits/resolver_policy.hpp>
Expand DownExpand Up@@ -97,7 +98,8 @@ struct http_sync_connection
connection_base::read_body(socket_, response_, response_buffer);
typename headers_range<basic_response<Tag> >::type connection_range =
headers(response_)["Connection"];
if (version_major == 1 && version_minor == 1 && !boost::empty(connection_range) &&
if (version_major == 1 && version_minor == 1 &&
!boost::empty(connection_range) &&
boost::iequals(boost::begin(connection_range)->second, "close")) {
close_socket();
} else if (version_major == 1 && version_minor == 0) {
Expand All@@ -109,19 +111,22 @@ struct http_sync_connection

void close_socket() {
timer_.cancel();
if (!is_open()) { return;
}
if (!is_open()) {
return;
}
boost::system::error_code ignored;
socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored);
if (ignored != nullptr) { return;
}
if (ignored != nullptr) {
return;
}
socket_.close(ignored);
}

private:
void handle_timeout(boost::system::error_code const& ec) {
if (!ec) { close_socket();
}
if (!ec) {
close_socket();
}
}

int timeout_;
Expand Down
77 changes: 42 additions & 35 deletionsboost/network/protocol/http/policies/pooled_connection.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,12 +7,12 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <boost/network/protocol/http/traits/resolver_policy.hpp>

#include <boost/algorithm/string/predicate.hpp>
#include <boost/network/protocol/http/client/connection/sync_base.hpp>
#include <boost/network/protocol/http/response.hpp>
#include <boost/network/protocol/http/traits/resolver_policy.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/unordered_map.hpp>
#include <utility>

Expand All@@ -37,7 +37,7 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {
system::error_code const&)> body_callback_function_type;
typedef function<bool(string_type&)> body_generator_function_type;

void cleanup() { host_connection_map().swap(host_connections); }
void cleanup() { host_connection_map().swap(host_connections_); }

struct connection_impl {
typedef function<shared_ptr<connection_impl>(
Expand All@@ -47,10 +47,10 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {
get_connection_function;

connection_impl(
resolver_type& resolver, bool follow_redirect, string_type /*unused*/const& host,
string_type const&port, resolver_function_type resolve,
get_connection_function get_connection, bool https,
bool always_verify_peer, int timeout,
resolver_type& resolver, bool follow_redirect,
string_type/*unused*/const&host, string_type const& port,
resolver_function_type resolve, get_connection_function get_connection,
boolhttps, boolalways_verify_peer, int timeout,
optional<string_type> const& certificate_filename =
optional<string_type>(),
optional<string_type> const& verify_path = optional<string_type>(),
Expand All@@ -77,7 +77,7 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {
(void)port;
}

basic_response<Tag> send_request(string_type /*unused*/const& method,
basic_response<Tag> send_request(string_type const& method,
basic_request<Tag> request_, bool get_body,
body_callback_function_type callback,
body_generator_function_type generator) {
Expand All@@ -86,7 +86,7 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {

private:
basic_response<Tag> send_request_impl(
string_type /*unused*/const& method, basic_request<Tag> request_, bool get_body,
string_type const& method, basic_request<Tag> request_, bool get_body,
body_callback_function_type callback,
body_generator_function_type generator) {
// TODO(dberris): review parameter necessity.
Expand All@@ -113,8 +113,7 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {

try {
pimpl->read_status(response_, response_buffer);
}
catch (boost::system::system_error& e) {
} catch (boost::system::system_error& e) {
if (!retry && e.code() == boost::asio::error::eof) {
retry = true;
pimpl->init_socket(request_.host(),
Expand DownExpand Up@@ -182,49 +181,57 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {

typedef shared_ptr<connection_impl> connection_ptr;

typedef unordered_map<string_type, connection_ptr> host_connection_map;
host_connection_map host_connections;
typedef unordered_map<string_type, weak_ptr<connection_impl>> host_connection_map;
boost::mutex host_mutex_;
host_connection_map host_connections_;
bool follow_redirect_;
int timeout_;

connection_ptr get_connection(
resolver_type& resolver, basic_request<Tag> const& request_,
bool always_verify_peer,
optional<string_type> /*unused*/const& certificate_filename =
optional<string_type> const& certificate_filename =
optional<string_type>(),
optional<string_type> const& verify_path = optional<string_type>(),
optional<string_type> const& certificate_file = optional<string_type>(),
optional<string_type> const& private_key_file = optional<string_type>(),
optional<string_type> const& ciphers = optional<string_type>()) {
string_type index =
(request_.host() + ':') + lexical_cast<string_type>(request_.port());
connection_ptr connection_;
typename host_connection_map::iterator it = host_connections.find(index);
if (it == host_connections.end()) {
connection_.reset(new connection_impl(
resolver, follow_redirect_, request_.host(),
lexical_cast<string_type>(request_.port()),
boost::bind(&pooled_connection_policy<Tag, version_major,
version_minor>::resolve,
this, boost::arg<1>(), boost::arg<2>(), boost::arg<3>()),
boost::bind(&pooled_connection_policy<Tag, version_major,
version_minor>::get_connection,
this, boost::arg<1>(), boost::arg<2>(),
always_verify_peer, boost::arg<3>(), boost::arg<4>(),
boost::arg<5>(), boost::arg<6>(), boost::arg<7>()),
boost::iequals(request_.protocol(), string_type("https")),
always_verify_peer, timeout_, certificate_filename, verify_path,
certificate_file, private_key_file, ciphers, 0));
host_connections.insert(std::make_pair(index, connection_));
return connection_;
boost::mutex::scoped_lock lock(host_mutex_);
auto it = host_connections_.find(index);
if (it != host_connections_.end()) {
// We've found an existing connection; but we should check if that
// connection hasn't been deleted yet.
auto result = it->second.lock();
if (!result) return result;
}
return it->second;

connection_ptr connection(new connection_impl(
resolver, follow_redirect_, request_.host(),
lexical_cast<string_type>(request_.port()),
// resolver function
boost::bind(&pooled_connection_policy<Tag, version_major,
version_minor>::resolve,
this, boost::arg<1>(), boost::arg<2>(), boost::arg<3>()),
// connection factory
boost::bind(&pooled_connection_policy<Tag, version_major,
version_minor>::get_connection,
this, boost::arg<1>(), boost::arg<2>(), always_verify_peer,
boost::arg<3>(), boost::arg<4>(), boost::arg<5>(),
boost::arg<6>(), boost::arg<7>()),
boost::iequals(request_.protocol(), string_type("https")),
always_verify_peer, timeout_, certificate_filename, verify_path,
certificate_file, private_key_file, ciphers, 0));
host_connections_.insert(std::make_pair(index, connection));
return connection;
}

pooled_connection_policy(bool cache_resolved, bool follow_redirect,
int timeout)
: resolver_base(cache_resolved),
host_connections(),
host_mutex_(),
host_connections_(),
follow_redirect_(follow_redirect),
timeout_(timeout) {}
};
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp