From e70691b8bd6b41cbbda6ad8a5d529e0d8ef96f44 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Wed, 8 Jun 2016 21:41:28 +0100 Subject: [PATCH 01/12] amending minor documentation mistake --- boost/cgi/basic_request.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boost/cgi/basic_request.hpp b/boost/cgi/basic_request.hpp index eef9d9e..a8c0127 100644 --- a/boost/cgi/basic_request.hpp +++ b/boost/cgi/basic_request.hpp @@ -84,9 +84,9 @@ BOOST_CGI_NAMESPACE_BEGIN /// The environment data, exposed as a `request_data`. env_data env; - /// The GET (ie. query string) data, exposed as a `request_data`. - post_data post; /// The POST data, exposed as a `request_data`. + post_data post; + /// The GET (ie. query string) data, exposed as a `request_data`. get_data get; /// The form data, which is either the GET or POST data. form_data form; From 5172b55c1717a8a2f2d1a1dfe5048366c2cb85da Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Thu, 9 Jun 2016 00:54:05 +0100 Subject: [PATCH 02/12] replacing deprecated asio::native_type with native_handle_type --- boost/cgi/basic_request_acceptor.hpp | 10 +++++----- boost/cgi/fcgi/acceptor_service_impl.hpp | 6 +++--- boost/cgi/fcgi/request_acceptor_service.hpp | 6 +++--- boost/cgi/fcgi/traits.hpp | 3 ++- boost/cgi/fcgi/win32_acceptor_service_impl.hpp | 6 +++--- boost/cgi/scgi/request_acceptor_service.hpp | 6 +++--- boost/cgi/scgi/traits.hpp | 3 ++- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/boost/cgi/basic_request_acceptor.hpp b/boost/cgi/basic_request_acceptor.hpp index b4d9243..de68eaa 100644 --- a/boost/cgi/basic_request_acceptor.hpp +++ b/boost/cgi/basic_request_acceptor.hpp @@ -37,7 +37,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef protocol_traits traits; typedef typename traits::acceptor_service service_type; typedef typename traits::endpoint_type endpoint_type; - typedef typename traits::native_type native_type; + typedef typename traits::native_handle_type native_handle_type; typedef typename traits::protocol_service_type protocol_service_type; typedef typename @@ -71,7 +71,7 @@ BOOST_CGI_NAMESPACE_BEGIN explicit basic_request_acceptor( common::basic_protocol_service& ps, const InternetProtocol& ip, - const native_type& native_acceptor) + const native_handle_type& native_acceptor) : boost::asio::basic_io_object(ps.get_io_service()) { this->service.set_protocol_service(this->implementation, ps); @@ -165,7 +165,7 @@ BOOST_CGI_NAMESPACE_BEGIN } template - void assign(InternetProtocol protocol, const native_type& native_acceptor) + void assign(InternetProtocol protocol, const native_handle_type& native_acceptor) { boost::system::error_code ec; this->service.assign(this->implementation, protocol, native_acceptor, ec); @@ -174,7 +174,7 @@ BOOST_CGI_NAMESPACE_BEGIN template boost::system::error_code - assign(InternetProtocol protocol, const native_type& native_acceptor + assign(InternetProtocol protocol, const native_handle_type& native_acceptor , boost::system::error_code& ec) { return this->service.assign(this->implementation, protocol @@ -246,7 +246,7 @@ BOOST_CGI_NAMESPACE_BEGIN return this->service.local_endpoint(this->implementation, ec); } - native_type + native_handle_type native() { return this->service.native(this->implementation); diff --git a/boost/cgi/fcgi/acceptor_service_impl.hpp b/boost/cgi/fcgi/acceptor_service_impl.hpp index 3a9baa7..78e06e1 100644 --- a/boost/cgi/fcgi/acceptor_service_impl.hpp +++ b/boost/cgi/fcgi/acceptor_service_impl.hpp @@ -76,7 +76,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef common::protocol_traits traits; typedef typename traits::protocol_service_type protocol_service_type; typedef typename traits::native_protocol_type native_protocol_type; - typedef typename traits::native_type native_type; + typedef typename traits::native_handle_type native_handle_type; typedef typename traits::request_type request_type; typedef typename traits::acceptor_service_type acceptor_service_type; typedef typename traits::acceptor_impl_type acceptor_impl_type; @@ -190,7 +190,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// Assign an existing native acceptor to a *socket* acceptor. boost::system::error_code assign(implementation_type& impl, const native_protocol_type& protocol - , const native_type& native_acceptor + , const native_handle_type& native_acceptor , boost::system::error_code& ec) { return acceptor_service_.assign(impl.acceptor_, protocol @@ -380,7 +380,7 @@ BOOST_CGI_NAMESPACE_BEGIN return acceptor_service_.local_endpoint(impl.acceptor_, ec); } - native_type + native_handle_type native(implementation_type& impl) { return acceptor_service_.native(impl.acceptor_); diff --git a/boost/cgi/fcgi/request_acceptor_service.hpp b/boost/cgi/fcgi/request_acceptor_service.hpp index a725b0c..de62f47 100644 --- a/boost/cgi/fcgi/request_acceptor_service.hpp +++ b/boost/cgi/fcgi/request_acceptor_service.hpp @@ -54,7 +54,7 @@ BOOST_CGI_NAMESPACE_BEGIN #endif // defined(BOOST_WINDOWS) typedef typename service_impl_type::implementation_type implementation_type; - typedef typename service_impl_type::native_type native_type; + typedef typename service_impl_type::native_handle_type native_handle_type; typedef typename service_impl_type::accept_handler_type accept_handler_type; /// The unique service identifier @@ -179,12 +179,12 @@ BOOST_CGI_NAMESPACE_BEGIN template boost::system::error_code assign(implementation_type& impl, InternetProtocol protocol - , const native_type& native_acceptor, boost::system::error_code& ec) + , const native_handle_type& native_acceptor, boost::system::error_code& ec) { return service_impl_.assign(impl, protocol, native_acceptor, ec); } - native_type native(implementation_type& impl) + native_handle_type native(implementation_type& impl) { return service_impl_.native(impl); } diff --git a/boost/cgi/fcgi/traits.hpp b/boost/cgi/fcgi/traits.hpp index 25f76eb..2ab8b4c 100644 --- a/boost/cgi/fcgi/traits.hpp +++ b/boost/cgi/fcgi/traits.hpp @@ -116,7 +116,8 @@ BOOST_CGI_NAMESPACE_BEGIN > acceptor_service_type; typedef acceptor_service_type::implementation_type acceptor_impl_type; - typedef acceptor_service_type::native_type native_type; + typedef acceptor_service_type::native_handle_type + native_handle_type; typedef native_protocol_type::endpoint endpoint_type; typedef form_parser form_parser_type; typedef fcgi::spec::header header_type; diff --git a/boost/cgi/fcgi/win32_acceptor_service_impl.hpp b/boost/cgi/fcgi/win32_acceptor_service_impl.hpp index 85f477e..70e5ebb 100644 --- a/boost/cgi/fcgi/win32_acceptor_service_impl.hpp +++ b/boost/cgi/fcgi/win32_acceptor_service_impl.hpp @@ -183,7 +183,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef common::protocol_traits traits; typedef typename traits::protocol_service_type protocol_service_type; typedef typename traits::native_protocol_type native_protocol_type; - typedef typename traits::native_type native_type; + typedef typename traits::native_handle_type native_handle_type; typedef typename traits::request_type request_type; typedef typename traits::acceptor_service_type acceptor_service_type; typedef typename traits::acceptor_impl_type acceptor_impl_type; @@ -310,7 +310,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// Assign an existing native acceptor to a *socket* acceptor. boost::system::error_code assign(implementation_type& impl, const native_protocol_type& protocol - , const native_type& native_acceptor + , const native_handle_type& native_acceptor , boost::system::error_code& ec) { return acceptor_service_.assign(impl.acceptor_, protocol @@ -539,7 +539,7 @@ BOOST_CGI_NAMESPACE_BEGIN return acceptor_service_.local_endpoint(impl.acceptor_, ec); } - native_type + native_handle_type native(implementation_type& impl) { return acceptor_service_.native(impl.acceptor_); diff --git a/boost/cgi/scgi/request_acceptor_service.hpp b/boost/cgi/scgi/request_acceptor_service.hpp index 0f35118..d44ad4a 100644 --- a/boost/cgi/scgi/request_acceptor_service.hpp +++ b/boost/cgi/scgi/request_acceptor_service.hpp @@ -48,7 +48,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef common::protocol_traits traits; typedef typename traits::protocol_service_type protocol_service_type; typedef typename traits::native_protocol_type native_protocol_type; - typedef typename traits::native_type native_type; + typedef typename traits::native_handle_type native_handle_type; typedef typename traits::request_type request_type; typedef typename traits::acceptor_service_type acceptor_service_type; typedef typename traits::acceptor_impl_type acceptor_impl_type; @@ -157,7 +157,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// Assign an existing native acceptor to a *socket* acceptor. boost::system::error_code assign(implementation_type& impl, const native_protocol_type& protocol - , const native_type& native_acceptor + , const native_handle_type& native_acceptor , boost::system::error_code& ec) { return acceptor_service_.assign(impl.acceptor_, protocol @@ -301,7 +301,7 @@ BOOST_CGI_NAMESPACE_BEGIN return acceptor_service_.local_endpoint(impl.acceptor_, ec); } - native_type + native_handle_type native(implementation_type& impl) { return acceptor_service_.native(impl.acceptor_); diff --git a/boost/cgi/scgi/traits.hpp b/boost/cgi/scgi/traits.hpp index 9a65c86..533504e 100644 --- a/boost/cgi/scgi/traits.hpp +++ b/boost/cgi/scgi/traits.hpp @@ -95,7 +95,8 @@ BOOST_CGI_NAMESPACE_BEGIN > acceptor_service_type; typedef acceptor_service_type::implementation_type acceptor_impl_type; - typedef acceptor_service_type::native_type native_type; + typedef acceptor_service_type::native_handle_type + native_handle_type; typedef native_protocol_type::endpoint endpoint_type; typedef form_parser form_parser_type; typedef boost::none_t header_type; From 75ee850843c662ff99989e7d5fd09be4cdb4c8f7 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Thu, 9 Jun 2016 22:03:24 +0100 Subject: [PATCH 03/12] default-initialising remainder of struct to quash uninitialised struct warning --- boost/cgi/common/request_base.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boost/cgi/common/request_base.hpp b/boost/cgi/common/request_base.hpp index d8887d8..a4e5cf9 100644 --- a/boost/cgi/common/request_base.hpp +++ b/boost/cgi/common/request_base.hpp @@ -389,6 +389,10 @@ BOOST_CGI_NAMESPACE_BEGIN , callback , impl.stdin_parsed_ , env_vars(impl.vars_)["REMOTE_ADDR"] + , 0 + , {} + , {} + , {} }; // Parse the current request. From e6b09bbf57fba5c412b58bf853fd9389d62f4258 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Thu, 9 Jun 2016 22:04:01 +0100 Subject: [PATCH 04/12] marking unused parameter with __attribute__((__unused__)) to quash compiler warnings --- boost/cgi/basic_client.hpp | 20 +++---- boost/cgi/common/commit.hpp | 2 +- boost/cgi/common/path_info.hpp | 20 +++---- boost/cgi/common/request_base.hpp | 40 ++++++------- boost/cgi/detail/extract_params.hpp | 6 +- boost/cgi/fcgi/acceptor_service_impl.hpp | 30 +++++----- boost/cgi/impl/fcgi_request_service.ipp | 74 ++++++++++++------------ 7 files changed, 96 insertions(+), 96 deletions(-) diff --git a/boost/cgi/basic_client.hpp b/boost/cgi/basic_client.hpp index 8a81e49..153da9e 100644 --- a/boost/cgi/basic_client.hpp +++ b/boost/cgi/basic_client.hpp @@ -27,7 +27,7 @@ BOOST_CGI_NAMESPACE_BEGIN namespace common { - + enum client_status { none_, // **FIXME** ! @@ -82,12 +82,12 @@ BOOST_CGI_NAMESPACE_BEGIN */ template boost::system::error_code - construct(RequestImpl& req, boost::system::error_code& ec) + construct(RequestImpl& req __attribute__((__unused__)), boost::system::error_code& ec) { status_ = constructed; return ec; } - + boost::system::error_code close(boost::uint64_t app_status, boost::system::error_code& ec) { @@ -182,7 +182,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// Get a shared_ptr of the connection associated with the client. connection_ptr& connection() { return connection_; } std::size_t& bytes_left() { return bytes_left_; } - + bool is_open() { return connection_->is_open(); @@ -204,32 +204,32 @@ BOOST_CGI_NAMESPACE_BEGIN { return keep_connection_; } - + boost::uint16_t const& request_id() const { return request_id_; } private: - + template void prepare_buffer(const ConstBufferSequence& buf) { /* NOOP */ } - + void handle_write( std::size_t bytes_transferred, boost::system::error_code& ec) { /* NOOP */ } - + //io_service& io_service_; connection_ptr connection_; public: // **FIXME** // we should never read more than content-length bytes. std::size_t bytes_left_; - + boost::uint16_t request_id_; client_status status_; - + boost::uint64_t total_sent_bytes_; boost::uint64_t total_sent_packets_; diff --git a/boost/cgi/common/commit.hpp b/boost/cgi/common/commit.hpp index 3a35395..6559ac7 100644 --- a/boost/cgi/common/commit.hpp +++ b/boost/cgi/common/commit.hpp @@ -30,7 +30,7 @@ BOOST_CGI_NAMESPACE_BEGIN int commit(Request& req, Response& resp, int program_status , boost::system::error_code& ec) { - typedef typename Request::string_type string_type; + typedef typename Request::string_type string_type __attribute__((__unused__)); #ifdef BOOST_CGI_ENABLE_SESSIONS if (!program_status) { diff --git a/boost/cgi/common/path_info.hpp b/boost/cgi/common/path_info.hpp index c1a29bf..6ac67b5 100644 --- a/boost/cgi/common/path_info.hpp +++ b/boost/cgi/common/path_info.hpp @@ -29,11 +29,11 @@ BOOST_CGI_NAMESPACE_BEGIN boost::algorithm::split( parts, value, boost::algorithm::is_any_of("/")); } - + string_type substr( - string_type const& str, + string_type const& str __attribute__((__unused__)), char ch, - bool include_char = true + bool include_char __attribute__((__unused__)) = true ) const { @@ -45,7 +45,7 @@ BOOST_CGI_NAMESPACE_BEGIN } public: - + template path_info(basic_request

& request) : value(request.env["path_info"]) @@ -58,17 +58,17 @@ BOOST_CGI_NAMESPACE_BEGIN { parse(); } - + value_type& operator[](int i) { return parts[i]; } - + value_type& string() { return value; } - + operator value_type& () { return value; } - + string_type stem() const { return substr(value, '/', false); } - + string_type extension() const { return substr(stem(), '.'); } - + iterator begin() { return parts.begin(); } iterator end() { return parts.end(); } const_iterator begin() const { return parts.begin(); } diff --git a/boost/cgi/common/request_base.hpp b/boost/cgi/common/request_base.hpp index a4e5cf9..ebb07df 100644 --- a/boost/cgi/common/request_base.hpp +++ b/boost/cgi/common/request_base.hpp @@ -91,7 +91,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef typename traits::session_manager_type session_manager_type; #endif // BOOST_CGI_ENABLE_SESSIONS - + protected: // impl_base is the common base class for all request types' // implementation_type and should be inherited by it. @@ -124,7 +124,7 @@ BOOST_CGI_NAMESPACE_BEGIN , common::post_map, common::cookie_map , common::upload_map, common::session_map > var_map_type; - + /// Construct. impl_base() : service_(NULL) @@ -137,7 +137,7 @@ BOOST_CGI_NAMESPACE_BEGIN , client_() , fp_(NULL) {} - + bool stdin_parsed() { return stdin_parsed_; } common::http::status_code& http_status() { return http_status_; } common::request_status status() const { return request_status_; } @@ -153,12 +153,12 @@ BOOST_CGI_NAMESPACE_BEGIN } protocol_service_type* service_; - + var_map_type vars_; buffer_type post_buffer_; /// Whether the post data has been parsed yet. bool stdin_parsed_; - + bool all_done_; // The number of bytes left to read (ie. content_length - bytes_read) @@ -168,15 +168,15 @@ BOOST_CGI_NAMESPACE_BEGIN common::request_status request_status_; client_type client_; - + boost::scoped_ptr fp_; std::vector form_parts_; }; - - + + public: - + /// Get the request ID of a FastCGI request, or 1. template boost::uint16_t const& request_id(ImplType& impl) const @@ -224,10 +224,10 @@ BOOST_CGI_NAMESPACE_BEGIN } template - void destroy(ImplType& impl) + void destroy(ImplType& impl __attribute__((__unused__))) { } - + /// Return the connection associated with the request template client_type& client(ImplType& impl) @@ -272,8 +272,8 @@ BOOST_CGI_NAMESPACE_BEGIN template bool is_open(ImplType& impl) { - return !impl.all_done_ - && impl.status() >= common::accepted + return !impl.all_done_ + && impl.status() >= common::accepted && impl.status() <= common::aborted && impl.client_.is_open(); } @@ -291,7 +291,7 @@ BOOST_CGI_NAMESPACE_BEGIN } std::string const& cl = env_vars(impl.vars_)["CONTENT_LENGTH"]; - // This will throw if the content-length isn't a valid number + // This will throw if the content-length isn't a valid number // (which shouldn't ever happen). impl.bytes_left_ = cl.empty() ? 0 : boost::lexical_cast(cl); @@ -305,7 +305,7 @@ BOOST_CGI_NAMESPACE_BEGIN if (!parse_get_vars(impl, ec)) return ec; } - + if (env_vars(impl.vars_)["REQUEST_METHOD"] == "POST" && parse_opts & common::parse_post_only) { @@ -338,7 +338,7 @@ BOOST_CGI_NAMESPACE_BEGIN ("", "=&", boost::keep_empty_tokens) , ec); status(impl, (common::request_status)(status(impl) | common::get_read)); - } + } return ec; } @@ -366,7 +366,7 @@ BOOST_CGI_NAMESPACE_BEGIN } return ec; } - + /// Read and parse the cgi POST meta variables. template boost::system::error_code& @@ -378,7 +378,7 @@ BOOST_CGI_NAMESPACE_BEGIN // Construct a form_parser instance. impl.fp_.reset(new typename ImplType::form_parser_type()); - // Create a context for this request. + // Create a context for this request. typename ImplType::form_parser_type::context context = { env_vars(impl.vars_)["CONTENT_TYPE"] @@ -398,7 +398,7 @@ BOOST_CGI_NAMESPACE_BEGIN // Parse the current request. impl.fp_->parse(context, ec); status(impl, (common::request_status)(status(impl) | common::post_read)); - } + } return ec; } @@ -423,7 +423,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// Generate a new UUID. boost::uuids::uuid make_uuid() { return generator_(); } - + private: session_manager_type session_mgr_; uuid_generator_type generator_; diff --git a/boost/cgi/detail/extract_params.hpp b/boost/cgi/detail/extract_params.hpp index af311e0..4b33cb2 100644 --- a/boost/cgi/detail/extract_params.hpp +++ b/boost/cgi/detail/extract_params.hpp @@ -37,7 +37,7 @@ BOOST_CGI_NAMESPACE_BEGIN return ec;// = boost::system::error_code(34, boost::system::errno_ecat); typedef typename boost::tokenizer tokenizer; - typedef typename Map::value_type value_type; + typedef typename Map::value_type value_type __attribute__((__unused__)); typedef typename Map::mapped_type mapped_type; tokenizer toker(input, separator); @@ -69,7 +69,7 @@ BOOST_CGI_NAMESPACE_BEGIN // guaranteed by the CGI spec to be kept, but you might want to use them. // You just have to define `BOOST_CGI_KEEP_EMPTY_VARS` (**TODO** currently // on by default). -// Note that you'll want to check that your server keeps empty query string +// Note that you'll want to check that your server keeps empty query string // parameters. mapped_type val(name.empty() ? "" : current_token); #if defined(BOOST_CGI_KEEP_EMPTY_VARS) @@ -87,7 +87,7 @@ BOOST_CGI_NAMESPACE_BEGIN current_token = url_decode_values ? url_decode(*iter) : *iter; } } - + mapped_type val(name.empty() ? "" : current_token); // Save the name if the last n/v pair has no value. if ( !name.empty() ) diff --git a/boost/cgi/fcgi/acceptor_service_impl.hpp b/boost/cgi/fcgi/acceptor_service_impl.hpp index 78e06e1..aa54307 100644 --- a/boost/cgi/fcgi/acceptor_service_impl.hpp +++ b/boost/cgi/fcgi/acceptor_service_impl.hpp @@ -102,7 +102,7 @@ BOOST_CGI_NAMESPACE_BEGIN std::set running_requests_; protocol_service_type* service_; endpoint_type endpoint_; - + }; explicit acceptor_service_impl(::BOOST_CGI_NAMESPACE::common::io_service& ios) @@ -202,12 +202,12 @@ BOOST_CGI_NAMESPACE_BEGIN { return acceptor_service_.listen(impl.acceptor_, backlog, ec); } - + void do_accept(implementation_type& impl , accept_handler_type handler) { request_ptr new_request; - + if (impl.waiting_requests_.empty()) { // Accepting on new request. @@ -219,9 +219,9 @@ BOOST_CGI_NAMESPACE_BEGIN new_request = impl.waiting_requests_.front(); impl.waiting_requests_.pop(); } - + impl.running_requests_.insert(new_request); - + // The waiting request may be open if it is a multiplexed request. // If we can reuse this request's connection, return. if (!new_request->is_open() && !new_request->client().keep_connection()) @@ -250,7 +250,7 @@ BOOST_CGI_NAMESPACE_BEGIN void handle_accept( implementation_type& impl, request_ptr new_request, - accept_handler_type handler, const boost::system::error_code& ec + accept_handler_type handler, const boost::system::error_code& ec __attribute__((__unused__)) ) { new_request->status(common::accepted); @@ -274,16 +274,16 @@ BOOST_CGI_NAMESPACE_BEGIN ); //); } - + int accept(implementation_type& impl, accept_handler_type handler , endpoint_type* endpoint, boost::system::error_code& ec) { typedef typename std::set::iterator iter_t; typedef std::pair pair_t; - + request_ptr new_request; pair_t insert_result; - + if (impl.waiting_requests_.empty()) { // Accepting on new request. @@ -295,9 +295,9 @@ BOOST_CGI_NAMESPACE_BEGIN new_request = impl.waiting_requests_.front(); impl.waiting_requests_.pop(); } - + insert_result = impl.running_requests_.insert(new_request); - + // The waiting request may be open if it is a multiplexed request. if (!new_request->is_open()) { @@ -311,14 +311,14 @@ BOOST_CGI_NAMESPACE_BEGIN } new_request->status(common::accepted); int status = handler(*new_request); - + impl.running_requests_.erase(insert_result.first); if (new_request->is_open()) { new_request->close(http::ok, status); } new_request->clear(); impl.waiting_requests_.push(new_request); - + return status; } @@ -394,13 +394,13 @@ BOOST_CGI_NAMESPACE_BEGIN static_cast(local_endpoint(impl,ec).capacity()) ); int check ( getpeername(native(impl), local_endpoint(impl,ec).data(), &len) ); - + /// The FastCGI check works differently on Windows and UNIX. #if defined(BOOST_WINDOWS) return ( check == SOCKET_ERROR && WSAGetLastError() == WSAENOTCONN ) ? false : true; #else - return ( check == -1 && + return ( check == -1 && errno == ENOTCONN ) ? false : true; #endif } diff --git a/boost/cgi/impl/fcgi_request_service.ipp b/boost/cgi/impl/fcgi_request_service.ipp index 135298f..0234a3f 100644 --- a/boost/cgi/impl/fcgi_request_service.ipp +++ b/boost/cgi/impl/fcgi_request_service.ipp @@ -62,7 +62,7 @@ BOOST_CGI_NAMESPACE_BEGIN return result; } - + /// Helper class to asynchronously load a request. /** * This is just a function object that can be posted to another @@ -93,7 +93,7 @@ BOOST_CGI_NAMESPACE_BEGIN common::parse_options parse_opts_; Handler handler_; }; - + struct clear_data { template @@ -105,7 +105,7 @@ BOOST_CGI_NAMESPACE_BEGIN } // namespace detail namespace fcgi { - + /// Close the request. template BOOST_CGI_INLINE int @@ -124,7 +124,7 @@ BOOST_CGI_NAMESPACE_BEGIN BOOST_CGI_INLINE int fcgi_request_service::close( implementation_type& impl - , http::status_code hsc + , http::status_code hsc __attribute__((__unused__)) , int program_status , boost::system::error_code& ec) { @@ -133,7 +133,7 @@ BOOST_CGI_NAMESPACE_BEGIN * pending data for the connection is read before the request * is closed. */ - while(!ec + while(!ec && impl.client_.status() < common::stdin_read && impl.request_status_ != common::loaded) { @@ -163,7 +163,7 @@ BOOST_CGI_NAMESPACE_BEGIN impl.client_.request_id_ = -1; impl.id_ = 0; } - + /// Load the request to a point where it can be usefully used. /** * FastCGI: @@ -230,7 +230,7 @@ BOOST_CGI_NAMESPACE_BEGIN impl.request_status_ = common::closed; return ec; } - + if (opts & common::parse_env) { read_env_vars(impl, ec); @@ -246,24 +246,24 @@ BOOST_CGI_NAMESPACE_BEGIN { if (opts & common::parse_post_only) { - while(!ec + while(!ec && impl.client_.status() < common::stdin_read && impl.request_status_ != common::loaded) { parse_packet(impl, ec); } } - + if (parse_post_vars(impl, ec)) return ec; } - + if (opts & common::parse_cookies_only) common::request_base::parse_cookie_vars(impl, "HTTP_COOKIE", ec); return ec; } - + template template BOOST_CGI_INLINE @@ -278,12 +278,12 @@ BOOST_CGI_NAMESPACE_BEGIN ec = error::client_not_open; } - + template template BOOST_CGI_INLINE void fcgi_request_service::handle_read_header( - implementation_type& impl, + implementation_type& impl, common::parse_options opts, Handler handler, boost::system::error_code& ec, @@ -308,7 +308,7 @@ BOOST_CGI_NAMESPACE_BEGIN handler(error::multiplexing_not_supported); } else - if (spec::get_type(impl.header_buf_) + if (spec::get_type(impl.header_buf_) == spec::begin_request::value) { impl.id_ = id; @@ -327,7 +327,7 @@ BOOST_CGI_NAMESPACE_BEGIN handle_other_request_header(impl); } } - + template template BOOST_CGI_INLINE @@ -347,34 +347,34 @@ BOOST_CGI_NAMESPACE_BEGIN string_type const& request_method (env_vars(impl.vars_)["REQUEST_METHOD"]); - + if (request_method == "GET") { if (common::request_base::parse_get_vars(impl, ec)) return; } else - if (request_method == "POST" + if (request_method == "POST" && opts & common::parse_post_only) { //std::cerr<< "Parsing post vars now.\n"; if (opts & common::parse_post_only) { - while(!ec + while(!ec && impl.client_.status() < common::stdin_read && impl.request_status_ != common::loaded) { parse_packet(impl, ec); } } - + if (parse_post_vars(impl, ec)) return; } if (opts & common::parse_cookies_only) common::request_base::parse_cookie_vars(impl, ec); - + if (ec == error::eof) { ec = boost::system::error_code(); } @@ -393,7 +393,7 @@ BOOST_CGI_NAMESPACE_BEGIN ) ); */ - + strand_.post( detail::async_load_helper(this, opts, handler) ); @@ -417,7 +417,7 @@ BOOST_CGI_NAMESPACE_BEGIN impl.client_.bytes_left_ = boost::lexical_cast( env_vars(impl.vars_)["CONTENT_LENGTH"]); - + return base_type::parse_post_vars( impl, detail::callback_functor(impl, this), @@ -447,7 +447,7 @@ BOOST_CGI_NAMESPACE_BEGIN { if (this->read_header(impl, ec)) return ec; - + boost::tribool state = this->parse_header(impl); if (state) @@ -492,7 +492,7 @@ BOOST_CGI_NAMESPACE_BEGIN impl.header_buf_ = header_buffer_type(); this->get_io_service().poll(); - async_read(*impl.client_.connection(), buffer(impl.header_buf_), [&](boost::system::error_code const &e, std::size_t bytes_transfered) -> void + async_read(*impl.client_.connection(), buffer(impl.header_buf_), [&](boost::system::error_code const &e, std::size_t bytes_transfered __attribute__((__unused__))) -> void { ec = e; }); @@ -503,7 +503,7 @@ BOOST_CGI_NAMESPACE_BEGIN if (this->get_io_service().stopped()) ec = error::eof; } - + return ec; } @@ -554,7 +554,7 @@ BOOST_CGI_NAMESPACE_BEGIN BOOST_CGI_INLINE void fcgi_request_service::handle_other_request_header(implementation_type& /* impl */) { - //std::cerr<< std::endl << "**FIXME** " << __FILE__ << ":" << __LINE__ + //std::cerr<< std::endl << "**FIXME** " << __FILE__ << ":" << __LINE__ // << " handle_other_request_header()" << std::endl; } @@ -562,7 +562,7 @@ BOOST_CGI_NAMESPACE_BEGIN BOOST_CGI_INLINE boost::system::error_code fcgi_request_service::process_abort_request( implementation_type& impl, boost::uint16_t id - , const unsigned char* buf, std::size_t len + , const unsigned char* buf __attribute__((__unused__)), std::size_t len __attribute__((__unused__)) , boost::system::error_code& ec) { if (id == fcgi::spec::get_request_id(impl.header_buf_)) @@ -583,13 +583,13 @@ BOOST_CGI_NAMESPACE_BEGIN template BOOST_CGI_INLINE boost::system::error_code fcgi_request_service::process_params( - implementation_type& impl, boost::uint16_t id + implementation_type& impl, boost::uint16_t id __attribute__((__unused__)) , const unsigned char* buf, std::size_t len , boost::system::error_code& ec) { if (0 == len) { // This is the final param record. - + impl.client_.status(common::params_read); return ec; } @@ -641,8 +641,8 @@ BOOST_CGI_NAMESPACE_BEGIN template BOOST_CGI_INLINE boost::system::error_code fcgi_request_service::process_stdin( - implementation_type& impl, boost::uint16_t id - , const unsigned char* buf,std::size_t len + implementation_type& impl, boost::uint16_t id __attribute__((__unused__)) + , const unsigned char* buf __attribute__((__unused__)),std::size_t len , boost::system::error_code& ec) { if (0 == len) @@ -738,7 +738,7 @@ BOOST_CGI_NAMESPACE_BEGIN boost::tribool state = this->parse_header(impl); if (state) - { + { // the header has been handled and all is ok. // **NOOP** } else @@ -821,7 +821,7 @@ BOOST_CGI_NAMESPACE_BEGIN // A begin request body is as long as a header, so we can optimise: if (read_header(impl, ec)) return ec; - + spec::begin_request packet(impl.header_buf_); impl.request_role_ = packet.role(); impl.client_.role_ = static_cast(packet.role()); @@ -829,7 +829,7 @@ BOOST_CGI_NAMESPACE_BEGIN = packet.flags() & spec::keep_connection; impl.client_.status_ = common::constructed; - + return ec; } @@ -845,8 +845,8 @@ BOOST_CGI_NAMESPACE_BEGIN template BOOST_CGI_INLINE boost::system::error_code fcgi_request_service::process_begin_request( - implementation_type& impl, boost::uint16_t id - , const unsigned char* buf, std::size_t len + implementation_type& impl, boost::uint16_t id __attribute__((__unused__)) + , const unsigned char* buf __attribute__((__unused__)), std::size_t len __attribute__((__unused__)) , boost::system::error_code& ec) { if (impl.client_.request_id_ == 0) // ie. hasn't been set yet. @@ -855,7 +855,7 @@ BOOST_CGI_NAMESPACE_BEGIN } else { - //std::cerr<< "**FIXME** Role: " + //std::cerr<< "**FIXME** Role: " // << fcgi::spec::begin_request::get_role(impl.header_buf_) << std::endl; //implementation_type::client_type::connection_type& From 34c547e759ef10c97f9efd00c173bbdbdd5d50f2 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Thu, 9 Jun 2016 22:11:55 +0100 Subject: [PATCH 05/12] spacing fix --- boost/cgi/common/commit.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boost/cgi/common/commit.hpp b/boost/cgi/common/commit.hpp index 6559ac7..ff85fcb 100644 --- a/boost/cgi/common/commit.hpp +++ b/boost/cgi/common/commit.hpp @@ -30,7 +30,7 @@ BOOST_CGI_NAMESPACE_BEGIN int commit(Request& req, Response& resp, int program_status , boost::system::error_code& ec) { - typedef typename Request::string_type string_type __attribute__((__unused__)); + typedef typename Request::string_type string_type __attribute__((__unused__)); #ifdef BOOST_CGI_ENABLE_SESSIONS if (!program_status) { From 526b1a6a6722125161ac542a3b891260d249dbcf Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Fri, 16 Feb 2018 16:19:13 +0000 Subject: [PATCH 06/12] add BOOST_ASIO_ENABLE_OLD_SERVICES macro which is necessary to compile successfully with boost 1.66 onwards --- boost/cgi/fcgi/traits.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/boost/cgi/fcgi/traits.hpp b/boost/cgi/fcgi/traits.hpp index 2ab8b4c..4c32d51 100644 --- a/boost/cgi/fcgi/traits.hpp +++ b/boost/cgi/fcgi/traits.hpp @@ -9,6 +9,8 @@ #ifndef BOOST_CGI_FCGI_TRAITS_HPP_INCLUDED_ #define BOOST_CGI_FCGI_TRAITS_HPP_INCLUDED_ +#define BOOST_ASIO_ENABLE_OLD_SERVICES + #include #include #include @@ -50,7 +52,7 @@ BOOST_CGI_NAMESPACE_BEGIN class fcgi_request_service; namespace common { - + /// Common Traits for FastCGI. template<> struct protocol_traits @@ -68,7 +70,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef basic_protocol_service< protocol_type > protocol_service_type; - typedef basic_request request_type; + typedef basic_request request_type; typedef basic_client client_type; #if defined(BOOST_WINDOWS) typedef basic_connection< @@ -114,7 +116,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef boost::asio::socket_acceptor_service< native_protocol_type > acceptor_service_type; - typedef + typedef acceptor_service_type::implementation_type acceptor_impl_type; typedef acceptor_service_type::native_handle_type native_handle_type; From 67ea093c5f63e7d0d0a4316ec37fa6eaa0dbd7b5 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Fri, 16 Feb 2018 17:47:56 +0000 Subject: [PATCH 07/12] switch to non-deprecated implementation and service getters --- boost/cgi/basic_request_acceptor.hpp | 68 ++++++++++++++-------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/boost/cgi/basic_request_acceptor.hpp b/boost/cgi/basic_request_acceptor.hpp index 4b725c1..32c10de 100644 --- a/boost/cgi/basic_request_acceptor.hpp +++ b/boost/cgi/basic_request_acceptor.hpp @@ -40,7 +40,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef typename traits::native_handle_type native_handle_type; typedef typename traits::protocol_service_type protocol_service_type; - typedef typename + typedef typename service_type::accept_handler_type accept_handler_type; template @@ -48,10 +48,10 @@ BOOST_CGI_NAMESPACE_BEGIN common::basic_protocol_service& ps) : boost::asio::basic_io_object(ps.get_io_service()) { - this->service.set_protocol_service(this->implementation, ps); + this->get_service().set_protocol_service(this->get_implementation(), ps); boost::system::error_code ec; - if (this->service.default_init(this->implementation, ec)) { + if (this->get_service().default_init(this->get_implementation(), ec)) { detail::throw_error(ec); } } @@ -63,7 +63,7 @@ BOOST_CGI_NAMESPACE_BEGIN bool reuse_addr = true) : boost::asio::basic_io_object(ps.get_io_service()) { - this->service.set_protocol_service(this->implementation, ps); + this->get_service().set_protocol_service(this->get_implementation(), ps); boost::system::error_code ec; open(endpoint.protocol(), ec); @@ -86,9 +86,9 @@ BOOST_CGI_NAMESPACE_BEGIN const native_handle_type& native_acceptor) : boost::asio::basic_io_object(ps.get_io_service()) { - this->service.set_protocol_service(this->implementation, ps); + this->get_service().set_protocol_service(this->get_implementation(), ps); boost::system::error_code ec; - this->service.assign(this->implementation, ip, native_acceptor, ec); + this->get_service().assign(this->get_implementation(), ip, native_acceptor, ec); detail::throw_error(ec); } @@ -98,13 +98,13 @@ BOOST_CGI_NAMESPACE_BEGIN protocol_service_type& protocol_service() const { - return this->service.protocol_service(this->implementation); + return this->get_service().protocol_service(this->get_implementation()); } /// Check if the acceptor is open bool is_open() { - return this->service.is_open(this->implementation); + return this->get_service().is_open(this->get_implementation()); } /// Open the acceptor @@ -112,7 +112,7 @@ BOOST_CGI_NAMESPACE_BEGIN void open(const InternetProtocol& protocol) { boost::system::error_code ec; - this->service.open(this->implementation, protocol, ec); + this->get_service().open(this->get_implementation(), protocol, ec); detail::throw_error(ec); } @@ -121,14 +121,14 @@ BOOST_CGI_NAMESPACE_BEGIN boost::system::error_code open(const InternetProtocol& protocol, boost::system::error_code& ec) { - return this->service.open(this->implementation, protocol, ec); + return this->get_service().open(this->get_implementation(), protocol, ec); } /// Set the acceptor to listen void listen(int backlog = boost::asio::socket_base::max_connections) { boost::system::error_code ec; - this->service.listen(this->implementation, backlog, ec); + this->get_service().listen(this->get_implementation(), backlog, ec); detail::throw_error(ec); } @@ -136,24 +136,24 @@ BOOST_CGI_NAMESPACE_BEGIN boost::system::error_code listen(int backlog, boost::system::error_code& ec) { - return this->service.listen(this->implementation, backlog, ec); + return this->get_service().listen(this->get_implementation(), backlog, ec); } template void bind(Endpoint& ep) { boost::system::error_code ec; - this->service.bind(this->implementation, ep, ec); + this->get_service().bind(this->get_implementation(), ep, ec); detail::throw_error(ec); - this->implementation.endpoint_ = ep; + this->get_implementation().endpoint_ = ep; } template boost::system::error_code bind(Endpoint& ep, boost::system::error_code& ec) { - ec = this->service.bind(this->implementation, ep, ec); - this->implementation.endpoint_ = ep; + ec = this->get_service().bind(this->get_implementation(), ep, ec); + this->get_implementation().endpoint_ = ep; return ec; } @@ -162,7 +162,7 @@ BOOST_CGI_NAMESPACE_BEGIN void set_option(const SettableSocketOption& option) { boost::system::error_code ec; - this->service.set_option(this->implementation, option, ec); + this->get_service().set_option(this->get_implementation(), option, ec); detail::throw_error(ec); } @@ -171,21 +171,21 @@ BOOST_CGI_NAMESPACE_BEGIN boost::system::error_code set_option(const SettableSocketOption& option, boost::system::error_code& ec) { - return this->service.set_option(this->implementation, option, ec); + return this->get_service().set_option(this->get_implementation(), option, ec); } /// Cancel all asynchronous operations associated with the acceptor. boost::system::error_code cancel() { - return this->service.cancel(this->implementation); + return this->get_service().cancel(this->get_implementation()); } /// Close the acceptor void close() { boost::system::error_code ec; - this->service.close(this->implementation, ec); + this->get_service().close(this->get_implementation(), ec); detail::throw_error(ec); } @@ -193,14 +193,14 @@ BOOST_CGI_NAMESPACE_BEGIN boost::system::error_code close(boost::system::error_code& ec) { - return this->service.close(this->implementation, ec); + return this->get_service().close(this->get_implementation(), ec); } template void assign(InternetProtocol protocol, const native_handle_type& native_acceptor) { boost::system::error_code ec; - this->service.assign(this->implementation, protocol, native_acceptor, ec); + this->get_service().assign(this->get_implementation(), protocol, native_acceptor, ec); detail::throw_error(ec); } @@ -209,7 +209,7 @@ BOOST_CGI_NAMESPACE_BEGIN assign(InternetProtocol protocol, const native_handle_type& native_acceptor , boost::system::error_code& ec) { - return this->service.assign(this->implementation, protocol + return this->get_service().assign(this->get_implementation(), protocol , native_acceptor, ec); } @@ -217,26 +217,26 @@ BOOST_CGI_NAMESPACE_BEGIN int accept(accept_handler_type handler) { boost::system::error_code ec; - int status = this->service.accept(this->implementation, handler, &this->implementation.endpoint_, ec); + int status = this->get_service().accept(this->get_implementation(), handler, &this->get_implementation().endpoint_, ec); detail::throw_error(ec); return status; } int accept(accept_handler_type handler, boost::system::error_code& ec) { - return this->service.accept(this->implementation, handler, &this->implementation.endpoint_, ec); + return this->get_service().accept(this->get_implementation(), handler, &this->get_implementation().endpoint_, ec); } void async_accept(accept_handler_type handler) { - this->service.async_accept(this->implementation, handler); + this->get_service().async_accept(this->get_implementation(), handler); } template void accept(CommonGatewayRequest& request) { boost::system::error_code ec; - this->service.accept(this->implementation, request, &this->implementation.endpoint_, ec); + this->get_service().accept(this->get_implementation(), request, &this->get_implementation().endpoint_, ec); detail::throw_error(ec); } @@ -245,7 +245,7 @@ BOOST_CGI_NAMESPACE_BEGIN boost::system::error_code accept(CommonGatewayRequest& request, boost::system::error_code& ec) { - return this->service.accept(this->implementation, request, &this->implementation.endpoint_, ec); + return this->get_service().accept(this->get_implementation(), request, &this->get_implementation().endpoint_, ec); } template @@ -253,21 +253,21 @@ BOOST_CGI_NAMESPACE_BEGIN accept(CommonGatewayRequest& request, endpoint_type& ep , boost::system::error_code& ec) { - return this->service.accept(this->implementation, request, &ep, ec); + return this->get_service().accept(this->get_implementation(), request, &ep, ec); } /// Asynchronously accept one request template void async_accept(CommonGatewayRequest& request, Handler handler) { - this->service.async_accept(this->implementation, request, handler); + this->get_service().async_accept(this->get_implementation(), request, handler); } endpoint_type local_endpoint() { boost::system::error_code ec; - endpoint_type ep(this->service.local_endpoint(this->implementation, ec)); + endpoint_type ep(this->get_service().local_endpoint(this->get_implementation(), ec)); detail::throw_error(ec); return ep; } @@ -275,18 +275,18 @@ BOOST_CGI_NAMESPACE_BEGIN endpoint_type local_endpoint(boost::system::error_code& ec) const { - return this->service.local_endpoint(this->implementation, ec); + return this->get_service().local_endpoint(this->get_implementation(), ec); } native_handle_type native() { - return this->service.native(this->implementation); + return this->get_service().native(this->get_implementation()); } bool is_cgi() { - return this->service.is_cgi(this->implementation); + return this->get_service().is_cgi(this->get_implementation()); } }; From 0a4267ece958a49cc240596a80989e09a6c3af24 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Fri, 16 Feb 2018 18:36:24 +0000 Subject: [PATCH 08/12] moving from deprecated pre-boost 1.66 const_buffers_1 and mutable_buffers_1 to new type see http://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/net_ts.html --- boost/cgi/cgi/traits.hpp | 4 ++-- boost/cgi/common/form_parser.hpp | 2 +- boost/cgi/fcgi/specification.hpp | 40 ++++++++++++++++---------------- boost/cgi/fcgi/traits.hpp | 4 ++-- boost/cgi/scgi/traits.hpp | 4 ++-- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/boost/cgi/cgi/traits.hpp b/boost/cgi/cgi/traits.hpp index fa98933..bec9eff 100644 --- a/boost/cgi/cgi/traits.hpp +++ b/boost/cgi/cgi/traits.hpp @@ -64,8 +64,8 @@ BOOST_CGI_NAMESPACE_BEGIN typedef std::basic_string string_type; typedef string_type buffer_type; typedef boost::array header_buffer_type; - typedef boost::asio::const_buffers_1 const_buffers_type; - typedef boost::asio::mutable_buffers_1 mutable_buffers_type; + typedef boost::asio::const_buffer const_buffers_type; + typedef boost::asio::mutable_buffer mutable_buffers_type; #ifdef BOOST_CGI_ENABLE_SESSIONS typedef basic_session< std::map diff --git a/boost/cgi/common/form_parser.hpp b/boost/cgi/common/form_parser.hpp index e0e972c..18a59db 100644 --- a/boost/cgi/common/form_parser.hpp +++ b/boost/cgi/common/form_parser.hpp @@ -80,7 +80,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef common::map map_type; typedef common::form_part::string_type string_type; typedef common::form_part::buffer_type buffer_type; - typedef boost::asio::mutable_buffers_1 mutable_buffers_type; + typedef boost::asio::mutable_buffer mutable_buffers_type; /// The context used for parsing. struct context diff --git a/boost/cgi/fcgi/specification.hpp b/boost/cgi/fcgi/specification.hpp index eb306e0..dee56dd 100644 --- a/boost/cgi/fcgi/specification.hpp +++ b/boost/cgi/fcgi/specification.hpp @@ -100,10 +100,10 @@ BOOST_CGI_NAMESPACE_BEGIN unsigned char paddingLength_; unsigned char reserved_; } impl; - + public: - typedef boost::asio::const_buffers_1 const_buffers_type; - typedef boost::asio::mutable_buffers_1 mutable_buffers_type; + typedef boost::asio::const_buffer const_buffers_type; + typedef boost::asio::mutable_buffer mutable_buffers_type; Header() { @@ -115,7 +115,7 @@ BOOST_CGI_NAMESPACE_BEGIN { reset(t, id, len); } - + mutable_buffers_type data() { return boost::asio::buffer( @@ -123,7 +123,7 @@ BOOST_CGI_NAMESPACE_BEGIN , sizeof(impl)); } - const_buffers_type data() const + const_buffers_type data() const { return boost::asio::buffer( static_cast(&impl) @@ -245,7 +245,7 @@ BOOST_CGI_NAMESPACE_BEGIN } impl; public: - typedef boost::asio::const_buffers_1 const_buffers_type; + typedef boost::asio::const_buffer const_buffers_type; EndRequestBody() {} @@ -266,8 +266,8 @@ BOOST_CGI_NAMESPACE_BEGIN memset(impl.reserved_, 0, sizeof(impl.reserved_)); } - - const_buffers_type data() const + + const_buffers_type data() const { return boost::asio::buffer( static_cast(&impl) @@ -351,10 +351,10 @@ BOOST_CGI_NAMESPACE_BEGIN impl.body_.reset( (unsigned char)type ); // not sure why this is C-style } }; - + #endif - } // namespace detail - + } // namespace detail + namespace specification { /// Define the FastCGI spec using types. @@ -369,26 +369,26 @@ BOOST_CGI_NAMESPACE_BEGIN struct header_length : boost::mpl::int_<8> {}; - + struct listensock_fileno : boost::mpl::int_<0> {}; static const unsigned char keep_connection = 1; - + struct null_request_id : boost::mpl::int_<0> {}; template int get_version(Array& a) { return static_cast(a[0]); } - + template spec_detail::request_types get_type(Array& a) { return static_cast(a[1]); } - + template boost::uint16_t get_request_id(Array& a) { @@ -449,7 +449,7 @@ BOOST_CGI_NAMESPACE_BEGIN } } }; - + typedef spec_detail::Header header; typedef spec_detail::EndRequestBody end_request_body; @@ -460,12 +460,12 @@ BOOST_CGI_NAMESPACE_BEGIN { typedef boost::mpl::int_<8> size; }; - + typedef boost::array< unsigned char , header_length::value > buffer_type; - + buffer_type impl; begin_request(buffer_type& buf) @@ -499,7 +499,7 @@ BOOST_CGI_NAMESPACE_BEGIN return a[2]; } }; - + struct stdout_header : spec_detail::Header { @@ -536,7 +536,7 @@ BOOST_CGI_NAMESPACE_BEGIN , end_request_body(app_status, proc_status) { } - + void reset ( int request_id diff --git a/boost/cgi/fcgi/traits.hpp b/boost/cgi/fcgi/traits.hpp index 4c32d51..6ec9200 100644 --- a/boost/cgi/fcgi/traits.hpp +++ b/boost/cgi/fcgi/traits.hpp @@ -101,8 +101,8 @@ BOOST_CGI_NAMESPACE_BEGIN // Internal types (advanced) typedef boost::array header_buffer_type; - typedef boost::asio::const_buffers_1 const_buffers_type; - typedef boost::asio::mutable_buffers_1 mutable_buffers_type; + typedef boost::asio::const_buffer const_buffers_type; + typedef boost::asio::mutable_buffer mutable_buffers_type; typedef fcgi::fcgi_request_service< protocol_type > request_service_type; diff --git a/boost/cgi/scgi/traits.hpp b/boost/cgi/scgi/traits.hpp index 533504e..b56cdec 100644 --- a/boost/cgi/scgi/traits.hpp +++ b/boost/cgi/scgi/traits.hpp @@ -102,8 +102,8 @@ BOOST_CGI_NAMESPACE_BEGIN typedef boost::none_t header_type; typedef boost::array header_buffer_type; - typedef boost::asio::const_buffers_1 const_buffers_type; - typedef boost::asio::mutable_buffers_1 mutable_buffers_type; + typedef boost::asio::const_buffer const_buffers_type; + typedef boost::asio::mutable_buffer mutable_buffers_type; }; } // namespace common From af7c4680551ea1bae7496f16869b2594522bd177 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Tue, 20 Feb 2018 00:10:39 +0000 Subject: [PATCH 09/12] replacing all deprecated asio functionality with latest as of boost 1.66 --- boost/cgi/basic_client.hpp | 4 +- boost/cgi/basic_request.hpp | 8 +- boost/cgi/basic_request_acceptor.hpp | 22 +-- boost/cgi/cgi/request_service.hpp | 4 +- boost/cgi/common/basic_protocol_service.hpp | 40 ++-- boost/cgi/common/has_hidden_io_service.hpp | 4 +- boost/cgi/common/io_service_provider.hpp | 172 +++++++++--------- boost/cgi/common/request_acceptor_service.hpp | 10 +- boost/cgi/common/request_service.hpp | 12 +- boost/cgi/common/tags.hpp | 2 +- boost/cgi/connections/anonymous_pipe.hpp | 16 +- boost/cgi/connections/async_stdio.hpp | 14 +- .../cgi/connections/shareable_tcp_socket.hpp | 4 +- boost/cgi/connections/tcp_socket.hpp | 4 +- boost/cgi/detail/basic_io_object.hpp | 40 ++-- boost/cgi/detail/basic_sync_io_object.hpp | 2 +- boost/cgi/detail/service_base.hpp | 6 +- boost/cgi/detail/service_id.hpp | 2 +- boost/cgi/fcgi/acceptor_service_impl.hpp | 12 +- boost/cgi/fcgi/client.hpp | 16 +- boost/cgi/fcgi/fcgi_connection.hpp | 4 +- boost/cgi/fcgi/request_acceptor_service.hpp | 6 +- boost/cgi/fcgi/request_service.hpp | 6 +- boost/cgi/fcgi/specification.hpp | 34 ++-- .../cgi/fcgi/win32_acceptor_service_impl.hpp | 8 +- boost/cgi/fwd/basic_protocol_service_fwd.hpp | 2 +- boost/cgi/fwd/io_service_provider_fwd.hpp | 2 +- boost/cgi/fwd/request_service_fwd.hpp | 2 +- boost/cgi/impl/basic_request.ipp | 6 +- boost/cgi/impl/fcgi_request_service.ipp | 19 +- boost/cgi/impl/response.ipp | 32 ++-- boost/cgi/import/io_service.hpp | 2 +- boost/cgi/scgi/request_acceptor_service.hpp | 4 +- boost/cgi/scgi/request_service.hpp | 6 +- boost/cgi/scgi/request_service.ipp | 2 +- 35 files changed, 266 insertions(+), 263 deletions(-) diff --git a/boost/cgi/basic_client.hpp b/boost/cgi/basic_client.hpp index 153da9e..c0d194e 100644 --- a/boost/cgi/basic_client.hpp +++ b/boost/cgi/basic_client.hpp @@ -118,7 +118,7 @@ BOOST_CGI_NAMESPACE_BEGIN return true; } - //io_service& io_service() { return io_service_; } + //io_context& io_context() { return io_context_; } /// Associate a connection with this client /** @@ -220,7 +220,7 @@ BOOST_CGI_NAMESPACE_BEGIN std::size_t bytes_transferred, boost::system::error_code& ec) { /* NOOP */ } - //io_service& io_service_; + //io_context& io_context_; connection_ptr connection_; public: // **FIXME** diff --git a/boost/cgi/basic_request.hpp b/boost/cgi/basic_request.hpp index a07cae1..1d47f19 100644 --- a/boost/cgi/basic_request.hpp +++ b/boost/cgi/basic_request.hpp @@ -126,7 +126,7 @@ BOOST_CGI_NAMESPACE_BEGIN basic_request(protocol_service_type& s , const parse_options opts = traits::parse_opts , char** base_env = NULL) - : detail::basic_io_object(s.get_io_service()) + : detail::basic_io_object(s.get_io_context()) { set_protocol_service(s); if (opts > parse_none) load(opts, base_env); @@ -137,7 +137,7 @@ BOOST_CGI_NAMESPACE_BEGIN , boost::system::error_code& ec , const parse_options opts = traits::parse_opts , char** base_env = NULL) - : detail::basic_io_object(s.get_io_service()) + : detail::basic_io_object(s.get_io_context()) { set_protocol_service(s); if (opts > parse_none) load(opts, ec, base_env); @@ -146,7 +146,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// Make a new mutiplexed request from an existing connection. // Throws. basic_request(implementation_type& impl) - : detail::basic_io_object(impl.service_->get_io_service()) + : detail::basic_io_object(impl.service_->get_io_context()) { set_protocol_service(*impl.service_); boost::system::error_code ec; @@ -158,7 +158,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// Make a new mutiplexed request from an existing connection. // Won't throw. basic_request(implementation_type& impl, boost::system::error_code& ec) - : detail::basic_io_object(impl.service_->get_io_service()) + : detail::basic_io_object(impl.service_->get_io_context()) { set_protocol_service(*impl.service_); this->service.begin_request_helper(this->implementation diff --git a/boost/cgi/basic_request_acceptor.hpp b/boost/cgi/basic_request_acceptor.hpp index 32c10de..552ba9d 100644 --- a/boost/cgi/basic_request_acceptor.hpp +++ b/boost/cgi/basic_request_acceptor.hpp @@ -43,10 +43,10 @@ BOOST_CGI_NAMESPACE_BEGIN typedef typename service_type::accept_handler_type accept_handler_type; - template + template explicit basic_request_acceptor( - common::basic_protocol_service& ps) - : boost::asio::basic_io_object(ps.get_io_service()) + common::basic_protocol_service& ps) + : boost::asio::basic_io_object(ps.get_io_context()) { this->get_service().set_protocol_service(this->get_implementation(), ps); @@ -56,12 +56,12 @@ BOOST_CGI_NAMESPACE_BEGIN } } - template + template explicit basic_request_acceptor( - common::basic_protocol_service& ps, + common::basic_protocol_service& ps, const boost::asio::ip::basic_endpoint& endpoint, bool reuse_addr = true) - : boost::asio::basic_io_object(ps.get_io_service()) + : boost::asio::basic_io_object(ps.get_io_context()) { this->get_service().set_protocol_service(this->get_implementation(), ps); @@ -75,16 +75,16 @@ BOOST_CGI_NAMESPACE_BEGIN } bind(endpoint, ec); detail::throw_error(ec); - listen(boost::asio::socket_base::max_connections, ec); + listen(boost::asio::socket_base::max_listen_connections, ec); detail::throw_error(ec); } - template + template explicit basic_request_acceptor( - common::basic_protocol_service& ps, + common::basic_protocol_service& ps, const InternetProtocol& ip, const native_handle_type& native_acceptor) - : boost::asio::basic_io_object(ps.get_io_service()) + : boost::asio::basic_io_object(ps.get_io_context()) { this->get_service().set_protocol_service(this->get_implementation(), ps); boost::system::error_code ec; @@ -125,7 +125,7 @@ BOOST_CGI_NAMESPACE_BEGIN } /// Set the acceptor to listen - void listen(int backlog = boost::asio::socket_base::max_connections) + void listen(int backlog = boost::asio::socket_base::max_listen_connections) { boost::system::error_code ec; this->get_service().listen(this->get_implementation(), backlog, ec); diff --git a/boost/cgi/cgi/request_service.hpp b/boost/cgi/cgi/request_service.hpp index e7b36a1..9dc4bb8 100644 --- a/boost/cgi/cgi/request_service.hpp +++ b/boost/cgi/cgi/request_service.hpp @@ -91,7 +91,7 @@ BOOST_CGI_NAMESPACE_BEGIN }; - cgi_request_service(common::io_service& ios) + cgi_request_service(common::io_context& ios) : detail::service_base(ios) { } @@ -99,7 +99,7 @@ BOOST_CGI_NAMESPACE_BEGIN void construct(implementation_type& impl) { impl.client_.set_connection( - connection_type::create(this->get_io_service()) + connection_type::create(this->get_io_context()) ); } diff --git a/boost/cgi/common/basic_protocol_service.hpp b/boost/cgi/common/basic_protocol_service.hpp index 97d147d..77e8963 100644 --- a/boost/cgi/common/basic_protocol_service.hpp +++ b/boost/cgi/common/basic_protocol_service.hpp @@ -29,14 +29,14 @@ BOOST_CGI_NAMESPACE_BEGIN /// Basic Protocol Service /** * Holds the request queue and the connection queue. - * It is also a wrapper around asio::io_service + * It is also a wrapper around asio::io_context */ - template + template class basic_protocol_service { public: typedef Protocol protocol_type; - typedef IoServiceProvider ios_provider_type; + typedef IoContextProvider ios_provider_type; typedef typename protocol_traits::type traits; typedef typename traits::string_type string_type; typedef typename traits::request_type request_type; @@ -51,7 +51,7 @@ BOOST_CGI_NAMESPACE_BEGIN { } - basic_protocol_service(boost::asio::io_service& ios) + basic_protocol_service(boost::asio::io_context& ios) : ios_provider_(ios) , request_set_() , request_queue_() @@ -62,9 +62,9 @@ BOOST_CGI_NAMESPACE_BEGIN { } - /// Run all the io_services contained by this service + /// Run all the io_contexts contained by this service /** - * This is equivalent to calling run() on each of the io_services held by + * This is equivalent to calling run() on each of the io_contexts held by * ios_provider_ */ void run() @@ -72,9 +72,9 @@ BOOST_CGI_NAMESPACE_BEGIN ios_provider_.run(); } - /// Stop all the io_services contained by this service + /// Stop all the io_contexts contained by this service /** - * This is equivalent to calling stop() on each of the io_services held by + * This is equivalent to calling stop() on each of the io_contexts held by * ios_provider_ */ void stop() @@ -82,10 +82,10 @@ BOOST_CGI_NAMESPACE_BEGIN ios_provider_.stop(); } - /// Reset all the io_services contained by this service + /// Reset all the io_contexts contained by this service /** * This deletes the request queue(s), aborts all running requests and then - * calls reset() on each of the io_services held by ios_provider_. There is + * calls reset() on each of the io_contexts held by ios_provider_. There is * no guarantee that requests will terminate immediately. */ void reset() @@ -100,28 +100,28 @@ BOOST_CGI_NAMESPACE_BEGIN return true; } - /// Return an available io_service from the IoServiceProvider + /// Return an available io_context from the IoContextProvider /** - * The order in which the underlying io_services are returned is determined - * by what policy the IoServiceProvider uses. + * The order in which the underlying io_contexts are returned is determined + * by what policy the IoContextProvider uses. */ - ::BOOST_CGI_NAMESPACE::common::io_service& get_io_service() + ::BOOST_CGI_NAMESPACE::common::io_context& get_io_context() { - return ios_provider_.get_io_service(); + return ios_provider_.get_io_context(); } - /// Post the handler through an available io_service + /// Post the handler through an available io_context template void post(Handler handler) { - ios_provider_.get_io_service().post(handler); + ios_provider_.get_io_context().post(handler); } - /// Dispatch a handler through an available io_service + /// Dispatch a handler through an available io_context template void dispatch(Handler handler) { - ios_provider_.get_io_service().dispatch(handler); + ios_provider_.get_io_context().dispatch(handler); } private: @@ -131,7 +131,7 @@ BOOST_CGI_NAMESPACE_BEGIN set_type request_set_; /// A std::queue of the waiting (ie. not-being-handled) requests. queue_type request_queue_; - + #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) friend typename traits::request_type; #else diff --git a/boost/cgi/common/has_hidden_io_service.hpp b/boost/cgi/common/has_hidden_io_service.hpp index 8910a1a..86abc67 100644 --- a/boost/cgi/common/has_hidden_io_service.hpp +++ b/boost/cgi/common/has_hidden_io_service.hpp @@ -18,13 +18,13 @@ BOOST_CGI_NAMESPACE_BEGIN namespace common { template - struct has_hidden_io_service + struct has_hidden_io_context : boost::mpl::bool_ { }; template<> - struct has_hidden_io_service + struct has_hidden_io_context : boost::mpl::bool_ { }; diff --git a/boost/cgi/common/io_service_provider.hpp b/boost/cgi/common/io_service_provider.hpp index 2cfc3f4..2113cfb 100644 --- a/boost/cgi/common/io_service_provider.hpp +++ b/boost/cgi/common/io_service_provider.hpp @@ -24,216 +24,216 @@ BOOST_CGI_NAMESPACE_BEGIN namespace common { - /// Hold a set number of io_services and return them based on the Policy + /// Hold a set number of io_contexts and return them based on the Policy /** * Contains six member functions: - * io_service() - returns a reference to an io_service - * stop() - stops all io_services - * run() - runs all io_services - * reset() - resets all io_services + * io_context() - returns a reference to an io_context + * stop() - stops all io_contexts + * run() - runs all io_contexts + * reset() - resets all io_contexts - * (strike) stop_one() - stops one (running) io_service - * (strike) run_one() - runs one (not-yet-started/reset) io_service + * (strike) stop_one() - stops one (running) io_context + * (strike) run_one() - runs one (not-yet-started/reset) io_context * - * It can also be set up so that only required io_services are run: - * each call to io_service() can get an io_service, call io_service::run() on + * It can also be set up so that only required io_contexts are run: + * each call to io_context() can get an io_context, call io_context::run() on * it and then return it. */ template - class io_service_provider + class io_context_provider : private boost::noncopyable { public: - io_service_provider(int) - : io_service_() + io_context_provider(int) + : io_context_() { } - io_service_provider() - : io_service_() + io_context_provider() + : io_context_() { } - ::BOOST_CGI_NAMESPACE::common::io_service& - get_io_service() + ::BOOST_CGI_NAMESPACE::common::io_context& + get_io_context() { - return io_service_; + return io_context_; } void run() { - io_service_.run(); + io_context_.run(); } void stop() { - io_service_.stop(); + io_context_.stop(); } void reset() { - io_service_.reset(); + io_context_.restart(); } private: - ::BOOST_CGI_NAMESPACE::common::io_service io_service_; + ::BOOST_CGI_NAMESPACE::common::io_context io_context_; }; /* template<> - class io_service_provider + class io_context_provider { public: - typedef std::list impl_type; + typedef std::list impl_type; - io_service_provider(int pool_size) - : io_services_(pool_size) - , current_(io_services_.begin()) + io_context_provider(int pool_size) + : io_contexts_(pool_size) + , current_(io_contexts_.begin()) { } - BOOST_CGI_NAMESPACE::io_service& io_service() + BOOST_CGI_NAMESPACE::io_context& io_context() { return boost::ref(*current_++); } void run() { - std::for_each(io_services_.begin(), io_services_.end() - , boost::bind(&BOOST_CGI_NAMESPACE::io_service::run, boost::ref(_1))); + std::for_each(io_contexts_.begin(), io_contexts_.end() + , boost::bind(&BOOST_CGI_NAMESPACE::io_context::run, boost::ref(_1))); } void stop() { - std::for_each(io_services_.begin(), io_services_.end() - , boost::bind(&BOOST_CGI_NAMESPACE::io_service::stop, boost::ref(_1))); + std::for_each(io_contexts_.begin(), io_contexts_.end() + , boost::bind(&BOOST_CGI_NAMESPACE::io_context::stop, boost::ref(_1))); } void reset() { - std::for_each(io_services_.begin(), io_services_.end() - , boost::bind(&BOOST_CGI_NAMESPACE::io_service::reset, boost::ref(_1))); + std::for_each(io_contexts_.begin(), io_contexts_.end() + , boost::bind(&BOOST_CGI_NAMESPACE::io_context::reset, boost::ref(_1))); } impl_type& impl() { - return io_services_; + return io_contexts_; } private: - impl_type io_services_; + impl_type io_contexts_; impl_type::iterator current_; }; */ - /// Specialization for multi-queue/single-io_service strategy + /// Specialization for multi-queue/single-io_context strategy /** - * Holds a reference to a passed in io_service. Use of this requires the - * user passes in an io_service on construction of the + * Holds a reference to a passed in io_context. Use of this requires the + * user passes in an io_context on construction of the * basic_protocol_service<>. */ /******************************** template - class io_service_provider<0, Policy> + class io_context_provider<0, Policy> : private boost::noncopyable { public: - io_service_provider(boost::asio::io_service& ios) - : io_service_(ios) + io_context_provider(boost::asio::io_context& ios) + : io_context_(ios) { } - boost::asio:io_service& io_service() + boost::asio:io_context& io_context() { - return io_service_; + return io_context_; } void run() { - io_service_.run(); + io_context_.run(); } void stop() { - io_service_.stop(); + io_context_.stop(); } void reset() { - io_service_.reset(); + io_context_.reset(); } private: - boost::asio::io_service& io_service_; + boost::asio::io_context& io_context_; }; ********************************/ /* - /// Specialization for io_service-per-queue strategy + /// Specialization for io_context-per-queue strategy template - class io_service_provider<1, Policy>//tags::> + class io_context_provider<1, Policy>//tags::> : private boost::noncopyable { public: - io_service_provider(int) - : io_service_() - , work_(io_service_) + io_context_provider(int) + : io_context_() + , work_(io_context_) { } - io_service_provider() - : io_service_() - , work_(io_service_) + io_context_provider() + : io_context_() + , work_(io_context_) { } - boost::asio::io_service& io_service() + boost::asio::io_context& io_context() { - return io_service_; + return io_context_; } private: - boost::asio::io_service io_service_; - boost::asio::io_service::work work_; + boost::asio::io_context io_context_; + boost::asio::io_context::work work_; }; - /// Specialization for a variable number of io_services + /// Specialization for a variable number of io_contexts template - class io_service_provider<-1, Policy>//tags::round_robin_pool> + class io_context_provider<-1, Policy>//tags::round_robin_pool> : private boost::noncopyable { - typedef boost::shared_ptr io_service_ptr; - typedef boost::shared_ptr work_ptr; + typedef boost::shared_ptr io_context_ptr; + typedef boost::shared_ptr work_ptr; public: - io_service_provider(int pool_size = 7) + io_context_provider(int pool_size = 7) : pos_(0) - , io_services_() -// , strand_(io_services_[0]) + , io_contexts_() +// , strand_(io_contexts_[0]) { if (pool_size == 0) - throw std::runtime_error("io_service_pool size is 0"); + throw std::runtime_error("io_context_pool size is 0"); - // Give all the io_services work to do so that their run() functions will + // Give all the io_contexts work to do so that their run() functions will // not exit until they are explicitly stopped. for (std::size_t i = 0; i < pool_size; ++i) { - io_service_ptr io_service(new boost::asio::io_service); - work_ptr work(new boost::asio::io_service::work(*io_service)); - io_services_.push_back(io_service); + io_context_ptr io_context(new boost::asio::io_context); + work_ptr work(new boost::asio::io_context::work(*io_context)); + io_contexts_.push_back(io_context); work_.push_back(work); } } void run() { - // Create a pool of threads to run all of the io_services. + // Create a pool of threads to run all of the io_contexts. std::vector > threads; - for (std::size_t i = 0; i < io_services_.size(); ++i) + for (std::size_t i = 0; i < io_contexts_.size(); ++i) { boost::shared_ptr - thread(new boost::thread(boost::bind(&boost::asio::io_service::run - , io_services_[i]))); + thread(new boost::thread(boost::bind(&boost::asio::io_context::run + , io_contexts_[i]))); threads.push_back(thread); } @@ -244,32 +244,32 @@ BOOST_CGI_NAMESPACE_BEGIN void stop() { - // Explicitly stop all io_services. - for (std::size_t i = 0; i < io_services_.size(); ++i) - io_services_[i]->stop(); + // Explicitly stop all io_contexts. + for (std::size_t i = 0; i < io_contexts_.size(); ++i) + io_contexts_[i]->stop(); } // NOT THREAD-SAFE (but should be) - boost::asio::io_service& io_service() + boost::asio::io_context& io_context() { - boost::asio::io_service& io_service = *io_services_[pos_]; - if (++pos_ == io_services_.size()) + boost::asio::io_context& io_context = *io_contexts_[pos_]; + if (++pos_ == io_contexts_.size()) pos_ = 0; - return io_service; + return io_context; } private: int pos_; - std::vector io_services_; + std::vector io_contexts_; std::vector work_; - //boost::asio::io_service::strand strand_; + //boost::asio::io_context::strand strand_; }; */ } // namespace common // **FIXME** - using common::io_service_provider; - + using common::io_context_provider; + BOOST_CGI_NAMESPACE_END #include "boost/cgi/detail/pop_options.hpp" diff --git a/boost/cgi/common/request_acceptor_service.hpp b/boost/cgi/common/request_acceptor_service.hpp index 1470805..1d7caaf 100644 --- a/boost/cgi/common/request_acceptor_service.hpp +++ b/boost/cgi/common/request_acceptor_service.hpp @@ -28,7 +28,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef Protocol protocol_type; request_acceptor_service(basic_protocol_service& s) - : detail::service_base(s.io_service()) + : detail::service_base(s.io_context()) { } @@ -58,8 +58,8 @@ BOOST_CGI_NAMESPACE_BEGIN { return service_impl_.accept(impl, request, ec); /* - boost::thread::mutex::scoped_lock lk(io_service_.mutex_); - if( !io_service_.request_queue_.empty() ) + boost::thread::mutex::scoped_lock lk(io_context_.mutex_); + if( !io_context_.request_queue_.empty() ) { request = pservice_.request_queue_.front(); pservice_.request_queue_.pop(); @@ -80,8 +80,8 @@ BOOST_CGI_NAMESPACE_BEGIN { service_impl_.async_accept(impl, request, handler); /* - boost::thread::mutex::scoped_lock lk(io_service_.mutex_); - if( !io_service_.request_queue_.empty() ) + boost::thread::mutex::scoped_lock lk(io_context_.mutex_); + if( !io_context_.request_queue_.empty() ) { request = pservice_.request_queue_.front(); pservice_.request_queue_.pop(); diff --git a/boost/cgi/common/request_service.hpp b/boost/cgi/common/request_service.hpp index 6aeecdd..1f17bb8 100644 --- a/boost/cgi/common/request_service.hpp +++ b/boost/cgi/common/request_service.hpp @@ -22,7 +22,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// The generic service class for basic_request<>s /** * Note: If the protocol is an asynchronous protocol, which means it requires - * access to a boost::asio::io_service instance, then this class becomes a + * access to a boost::asio::io_context instance, then this class becomes a * model of the Service concept (**LINK**) and must only use the constructor * which takes a ProtocolService (**LINK**). If the protocol isn't async then * the class can be used without a ProtocolService. @@ -37,20 +37,20 @@ BOOST_CGI_NAMESPACE_BEGIN public: typedef typename service_impl_type::impl_type impl_type; - typedef typename + typedef typename service_impl_type::implementation_type implementation_type; typedef Protocol protocol_type; typedef common::basic_protocol_service protocol_service_type; - request_service(::BOOST_CGI_NAMESPACE::common::io_service& ios) + request_service(::BOOST_CGI_NAMESPACE::common::io_context& ios) : detail::service_base >(ios) , service_impl_(boost::asio::use_service(ios)) { } request_service(protocol_service_type& ps) - : detail::service_base >(ps.io_service()) - , service_impl_(boost::asio::use_service(ps.io_service())) + : detail::service_base >(ps.io_context()) + , service_impl_(boost::asio::use_service(ps.io_context())) { } @@ -80,7 +80,7 @@ BOOST_CGI_NAMESPACE_BEGIN //void construct - boost::system::error_code& + boost::system::error_code& load(impl_type& impl, bool parse_stdin, boost::system::error_code& ec) { return service_impl_.load(impl, parse_stdin, ec); diff --git a/boost/cgi/common/tags.hpp b/boost/cgi/common/tags.hpp index fb22e56..5487741 100644 --- a/boost/cgi/common/tags.hpp +++ b/boost/cgi/common/tags.hpp @@ -29,7 +29,7 @@ BOOST_CGI_NAMESPACE_BEGIN struct scgi {}; struct http {}; - // IoServiceProvider PoolingPolicy types + // IoContextProvider PoolingPolicy types struct single_service {}; struct service_pool {}; struct round_robin {}; diff --git a/boost/cgi/connections/anonymous_pipe.hpp b/boost/cgi/connections/anonymous_pipe.hpp index 6f13d28..e929c59 100644 --- a/boost/cgi/connections/anonymous_pipe.hpp +++ b/boost/cgi/connections/anonymous_pipe.hpp @@ -51,8 +51,8 @@ BOOST_CGI_NAMESPACE_BEGIN typedef boost::shared_ptr pointer; typedef HANDLE native_handle_type; - basic_connection(boost::asio::io_service& ios) - : io_service(ios) + basic_connection(boost::asio::io_context& ios) + : io_context(ios) , file_handle(INVALID_HANDLE_VALUE) , do_io_(true) { @@ -73,7 +73,7 @@ BOOST_CGI_NAMESPACE_BEGIN io_thread_->join(); } - static pointer create(boost::asio::io_service& ios) + static pointer create(boost::asio::io_context& ios) { return pointer(new self_type(ios)); } @@ -243,7 +243,7 @@ BOOST_CGI_NAMESPACE_BEGIN io_.notify_one(); } - boost::asio::io_service& io_service; + boost::asio::io_context& io_context; native_handle_type file_handle; private: @@ -259,10 +259,10 @@ BOOST_CGI_NAMESPACE_BEGIN }; typedef std::deque> read_queue_t; - typedef std::deque const_buffers_t; + typedef std::deque mutable_buffers_t; struct write_context { - const_buffers_t buffers; + mutable_buffers_t buffers; handler_t handler; }; typedef std::deque> write_queue_t; @@ -313,7 +313,7 @@ BOOST_CGI_NAMESPACE_BEGIN boost::system::error_code ec; std::size_t bytes_transfered = write_some(cntxt->buffers, ec); handler_t handler = cntxt->handler; - this->io_service.post([=]() -> void + this->io_context.post([=]() -> void { handler(ec, bytes_transfered); }); @@ -339,7 +339,7 @@ BOOST_CGI_NAMESPACE_BEGIN boost::system::error_code ec; std::size_t bytes_transfered = read_some(cntxt->buffers, ec); handler_t handler = cntxt->handler; - io_service.post([=]() -> void + io_context.post([=]() -> void { handler(ec, bytes_transfered); }); diff --git a/boost/cgi/connections/async_stdio.hpp b/boost/cgi/connections/async_stdio.hpp index bbfcbcd..99cd0e4 100644 --- a/boost/cgi/connections/async_stdio.hpp +++ b/boost/cgi/connections/async_stdio.hpp @@ -24,7 +24,7 @@ BOOST_CGI_NAMESPACE_BEGIN // Asynchronous access to stdio. /** * This class doesn't do real async I/O, but fakes it by posting - * a read / write to an io_service, which may be run in a background + * a read / write to an io_context, which may be run in a background * thread. On most systems this won't actually mean true async I/O, * but this emulates it as an interim solution. */ @@ -37,9 +37,9 @@ BOOST_CGI_NAMESPACE_BEGIN typedef basic_connection type; typedef boost::shared_ptr pointer; - basic_connection(common::io_service& ios) + basic_connection(common::io_context& ios) : basic_connection() - , io_service_(ios) + , io_context_(ios) { } @@ -53,7 +53,7 @@ BOOST_CGI_NAMESPACE_BEGIN is_open_ = false; } - static pointer create(::BOOST_CGI_NAMESPACE::common::io_service& ios) + static pointer create(::BOOST_CGI_NAMESPACE::common::io_context& ios) { return pointer(new basic_connection(ios)); } @@ -87,7 +87,7 @@ BOOST_CGI_NAMESPACE_BEGIN template void async_read_some(const MutableBufferSequence& buf, Handler handler) { - io_service_.post(read_handler + io_context_.post(read_handler (shared_from_this(), buf, handler)); } @@ -120,12 +120,12 @@ BOOST_CGI_NAMESPACE_BEGIN template void async_write_some(const ConstBufferSequence& buf, Handler handler) { - io_service_.post(write_handler + io_context_.post(write_handler (shared_from_this(), buf, handler)); } private: - ::BOOST_CGI_NAMESPACE::common::io_service& io_service_; + ::BOOST_CGI_NAMESPACE::common::io_context& io_context_; }; } // namespace common diff --git a/boost/cgi/connections/shareable_tcp_socket.hpp b/boost/cgi/connections/shareable_tcp_socket.hpp index cb664b5..6b05e9a 100644 --- a/boost/cgi/connections/shareable_tcp_socket.hpp +++ b/boost/cgi/connections/shareable_tcp_socket.hpp @@ -62,7 +62,7 @@ BOOST_CGI_NAMESPACE_BEGIN /** End FastCGI stuff **/ // A wrapper to provide condition_type::pointer - basic_connection(io_service& ios) + basic_connection(io_context& ios) : sock_(ios) , mutex_() , condition_() @@ -109,7 +109,7 @@ BOOST_CGI_NAMESPACE_BEGIN condition_.wait(lock); } - static pointer create(io_service& ios) + static pointer create(io_context& ios) { return //static_cast( pointer(new basic_connection(ios)); diff --git a/boost/cgi/connections/tcp_socket.hpp b/boost/cgi/connections/tcp_socket.hpp index f44c743..f3aa290 100644 --- a/boost/cgi/connections/tcp_socket.hpp +++ b/boost/cgi/connections/tcp_socket.hpp @@ -30,7 +30,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef boost::shared_ptr pointer; typedef boost::asio::ip::tcp::socket next_layer_type; - basic_connection(io_service& ios) + basic_connection(io_context& ios) : sock_(ios) { } @@ -45,7 +45,7 @@ BOOST_CGI_NAMESPACE_BEGIN sock_.close(); } - static pointer create(io_service& ios) + static pointer create(io_context& ios) { return pointer(new basic_connection(ios)); } diff --git a/boost/cgi/detail/basic_io_object.hpp b/boost/cgi/detail/basic_io_object.hpp index 577b851..4e87e3a 100644 --- a/boost/cgi/detail/basic_io_object.hpp +++ b/boost/cgi/detail/basic_io_object.hpp @@ -28,17 +28,17 @@ BOOST_CGI_NAMESPACE_BEGIN typedef Service service_type; typedef typename service_type::implementation_type implementation_type; - /// Get the io_service associated with the object. + /// Get the io_context associated with the object. /** - * This function may be used to obtain the io_service object that the I/O + * This function may be used to obtain the io_context object that the I/O * object uses to dispatch handlers for asynchronous operations. * - * @return A reference to the io_service object that the I/O object will + * @return A reference to the io_context object that the I/O object will * use to dispatch handlers. Ownership is not transferred to the caller. */ - boost::asio::io_service& get_io_service() + boost::asio::io_context& get_io_context() { - return service.get_io_service(); + return service.get_io_context(); } protected: @@ -56,7 +56,7 @@ BOOST_CGI_NAMESPACE_BEGIN implementation_type implementation; }; - /// basic_io_object alternative when an io_service isn't used + /// basic_io_object alternative when an io_context isn't used template class basic_io_object< Service, @@ -77,17 +77,17 @@ BOOST_CGI_NAMESPACE_BEGIN typedef Service service_type; typedef typename Service::implementation_type implementation_type; - /// Get the io_service associated with the object. + /// Get the io_context associated with the object. /** - * This function may be used to obtain the io_service object that the I/O + * This function may be used to obtain the io_context object that the I/O * object uses to dispatch handlers for asynchronous operations. * - * @return A reference to the io_service object that the I/O object will + * @return A reference to the io_context object that the I/O object will * use to dispatch handlers. Ownership is not transferred to the caller. */ - boost::asio::io_service& get_io_service() + boost::asio::io_context& get_io_context() { - return service.get_io_service(); + return service.get_io_context(); } protected: @@ -96,8 +96,8 @@ BOOST_CGI_NAMESPACE_BEGIN * Performs: * @code service.construct(implementation); @endcode */ - explicit basic_io_object(boost::asio::io_service& io_service) - : service(boost::asio::use_service(io_service)) + explicit basic_io_object(boost::asio::io_context& io_context) + : service(boost::asio::use_service(io_context)) { service.construct(implementation); } @@ -111,7 +111,7 @@ BOOST_CGI_NAMESPACE_BEGIN implementation_type implementation; }; - /// basic_io_object alternative when an io_service isn't used + /// basic_io_object alternative when an io_context isn't used template class basic_io_object< Service, @@ -127,17 +127,17 @@ BOOST_CGI_NAMESPACE_BEGIN typedef Service service_type; typedef typename Service::implementation_type implementation_type; - /// Get the io_service associated with the object. + /// Get the io_context associated with the object. /** - * This function may be used to obtain the io_service object that the I/O + * This function may be used to obtain the io_context object that the I/O * object uses to dispatch handlers for asynchronous operations. * - * @return A reference to the io_service object that the I/O object will + * @return A reference to the io_context object that the I/O object will * use to dispatch handlers. Ownership is not transferred to the caller. */ - boost::asio::io_service& get_io_service() + boost::asio::io_context& get_io_context() { - return service.get_io_service(); + return service.get_io_context(); } protected: @@ -158,7 +158,7 @@ BOOST_CGI_NAMESPACE_BEGIN service.destroy(implementation); } - boost::asio::io_service ios; + boost::asio::io_context ios; service_type& service; implementation_type implementation; }; diff --git a/boost/cgi/detail/basic_sync_io_object.hpp b/boost/cgi/detail/basic_sync_io_object.hpp index 0552d56..9cd8ea3 100644 --- a/boost/cgi/detail/basic_sync_io_object.hpp +++ b/boost/cgi/detail/basic_sync_io_object.hpp @@ -14,7 +14,7 @@ BOOST_CGI_NAMESPACE_BEGIN namespace detail { - /// basic_io_object alternative when an io_service isn't used + /// basic_io_object alternative when an io_context isn't used template class basic_sync_io_object : private boost::noncopyable diff --git a/boost/cgi/detail/service_base.hpp b/boost/cgi/detail/service_base.hpp index 0adbc66..c6c639d 100644 --- a/boost/cgi/detail/service_base.hpp +++ b/boost/cgi/detail/service_base.hpp @@ -25,14 +25,14 @@ BOOST_CGI_NAMESPACE_BEGIN // Special service base class to keep classes header-file only. template class service_base - : public boost::asio::io_service::service + : public boost::asio::io_context::service { public: static boost::asio::detail::service_id id; // Constructor. - service_base(boost::asio::io_service& io_service) - : boost::asio::io_service::service(io_service) + service_base(boost::asio::io_context& io_context) + : boost::asio::io_context::service(io_context) { } }; diff --git a/boost/cgi/detail/service_id.hpp b/boost/cgi/detail/service_id.hpp index ad51a99..5af4ea8 100644 --- a/boost/cgi/detail/service_id.hpp +++ b/boost/cgi/detail/service_id.hpp @@ -22,7 +22,7 @@ BOOST_CGI_NAMESPACE_BEGIN // Special derived service id type to keep classes header-file only. template class service_id - : public boost::asio::io_service::id + : public boost::asio::io_context::id { }; diff --git a/boost/cgi/fcgi/acceptor_service_impl.hpp b/boost/cgi/fcgi/acceptor_service_impl.hpp index 9f1ccf7..d66b900 100644 --- a/boost/cgi/fcgi/acceptor_service_impl.hpp +++ b/boost/cgi/fcgi/acceptor_service_impl.hpp @@ -105,7 +105,7 @@ BOOST_CGI_NAMESPACE_BEGIN }; - explicit acceptor_service_impl(::BOOST_CGI_NAMESPACE::common::io_service& ios) + explicit acceptor_service_impl(::BOOST_CGI_NAMESPACE::common::io_context& ios) : detail::service_base< ::BOOST_CGI_NAMESPACE::fcgi::acceptor_service_impl >(ios) , acceptor_service_(boost::asio::use_service(ios)) , strand_(ios) @@ -235,7 +235,8 @@ BOOST_CGI_NAMESPACE_BEGIN // ...otherwise accept a new connection. acceptor_service_.async_accept(impl.acceptor_, new_request->client().connection()->next_layer(), 0, - strand_.wrap( + boost::asio::bind_executor( + strand_, boost::bind(&self_type::handle_accept , this, boost::ref(impl), new_request, handler, _1 ) @@ -245,7 +246,8 @@ BOOST_CGI_NAMESPACE_BEGIN else { impl.service_->post( - strand_.wrap( + boost::asio::bind_executor( + strand_, boost::bind(&self_type::handle_accept , this, boost::ref(impl), new_request, handler, boost::system::error_code() ) @@ -364,7 +366,7 @@ BOOST_CGI_NAMESPACE_BEGIN , typename implementation_type::request_type& request , Handler handler) { - this->get_io_service().post( + this->get_io_context().post( detail::accept_handler(*this, impl, request, handler) ); } @@ -441,7 +443,7 @@ BOOST_CGI_NAMESPACE_BEGIN public: /// The underlying socket acceptor service. acceptor_service_type& acceptor_service_; - boost::asio::io_service::strand strand_; + boost::asio::io_context::strand strand_; }; } // namespace fcgi diff --git a/boost/cgi/fcgi/client.hpp b/boost/cgi/fcgi/client.hpp index 9093b3c..44c10e1 100644 --- a/boost/cgi/fcgi/client.hpp +++ b/boost/cgi/fcgi/client.hpp @@ -119,7 +119,7 @@ BOOST_CGI_NAMESPACE_BEGIN >::prepare_buffer(const ConstBufferSequence& buf) { typename ConstBufferSequence::const_iterator iter = buf.begin(); - typename ConstBufferSequence::const_iterator end = buf.end(); + typename ConstBufferSequence::const_iterator end = buf.end(); outbuf_.clear(); outbuf_.push_back(boost::asio::buffer(header_.data())); @@ -158,7 +158,7 @@ BOOST_CGI_NAMESPACE_BEGIN } header_.reset(fcgi::spec_detail::STDOUT, request_id_, total_buffer_size); } - + template<> void basic_client< @@ -167,14 +167,14 @@ BOOST_CGI_NAMESPACE_BEGIN { total_sent_bytes_ += bytes_transferred; total_sent_packets_ += 1; - + std::size_t total_buffer_size = static_cast(header_.content_length()); - + #if !defined(BOOST_CGI_NO_LOGGING) && !defined(NDEBUG) std::ofstream log("../logs/fcgi_client.log", std::ios::out | std::ios::app); if (ec) std::cerr<< "Error " << ec << ": " << ec.message() << '\n'; - else + else //std::cerr log << "Transferred " << total_buffer_size @@ -201,7 +201,7 @@ BOOST_CGI_NAMESPACE_BEGIN */ template<> template - std::size_t + std::size_t basic_client< ::BOOST_CGI_NAMESPACE::common::tags::fcgi >::write_some( @@ -210,13 +210,13 @@ BOOST_CGI_NAMESPACE_BEGIN ) { prepare_buffer(buf); - + std::size_t bytes_transferred = boost::asio::write(*connection_, outbuf_ , boost::asio::transfer_all(), ec); handle_write(bytes_transferred, ec); - + return bytes_transferred; } diff --git a/boost/cgi/fcgi/fcgi_connection.hpp b/boost/cgi/fcgi/fcgi_connection.hpp index b0508f6..f3afcac 100644 --- a/boost/cgi/fcgi/fcgi_connection.hpp +++ b/boost/cgi/fcgi/fcgi_connection.hpp @@ -28,7 +28,7 @@ BOOST_CGI_NAMESPACE_BEGIN typedef basic_connection type; typedef boost::shared_ptr pointer; - basic_connection(io_service& ios) + basic_connection(io_context& ios) : transport_(detail::transport_type()) { if (transport_ == detail::transport::pipe) @@ -58,7 +58,7 @@ BOOST_CGI_NAMESPACE_BEGIN socket_->close(); } - static pointer create(io_service& ios) + static pointer create(io_context& ios) { return pointer( new basic_connection(ios)); } diff --git a/boost/cgi/fcgi/request_acceptor_service.hpp b/boost/cgi/fcgi/request_acceptor_service.hpp index 7fa3c32..a4f7a04 100644 --- a/boost/cgi/fcgi/request_acceptor_service.hpp +++ b/boost/cgi/fcgi/request_acceptor_service.hpp @@ -29,7 +29,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// The service class for FCGI basic_request_acceptor<>s /** * Note: If the protocol is an asynchronous protocol, which means it - * requires access to a boost::asio::io_service instance, then this class + * requires access to a boost::asio::io_context instance, then this class * becomes a model of the Service concept (**LINK**) and must only use the * constructor which takes a ProtocolService (**LINK**). If the protocol * isn't async then the class can be used without a ProtocolService. @@ -58,9 +58,9 @@ BOOST_CGI_NAMESPACE_BEGIN typedef typename service_impl_type::accept_handler_type accept_handler_type; /// The unique service identifier - //static boost::asio::io_service::id id; + //static boost::asio::io_context::id id; - fcgi_request_acceptor_service(common::io_service& ios) + fcgi_request_acceptor_service(common::io_context& ios) : detail::service_base >(ios) , service_impl_(ios) { diff --git a/boost/cgi/fcgi/request_service.hpp b/boost/cgi/fcgi/request_service.hpp index 7845a5c..d9d9b81 100644 --- a/boost/cgi/fcgi/request_service.hpp +++ b/boost/cgi/fcgi/request_service.hpp @@ -87,7 +87,7 @@ BOOST_CGI_NAMESPACE_BEGIN } }; - fcgi_request_service(::BOOST_CGI_NAMESPACE::common::io_service& ios) + fcgi_request_service(::BOOST_CGI_NAMESPACE::common::io_context& ios) : detail::service_base >(ios) , strand_(ios) { @@ -100,7 +100,7 @@ BOOST_CGI_NAMESPACE_BEGIN void construct(implementation_type& impl) { impl.client_.set_connection( - implementation_type::connection_type::create(this->get_io_service()) + implementation_type::connection_type::create(this->get_io_context()) ); } @@ -281,7 +281,7 @@ BOOST_CGI_NAMESPACE_BEGIN , boost::system::error_code& ec); private: - boost::asio::io_service::strand strand_; + boost::asio::io_context::strand strand_; }; } // namespace fcgi diff --git a/boost/cgi/fcgi/specification.hpp b/boost/cgi/fcgi/specification.hpp index dee56dd..71023cf 100644 --- a/boost/cgi/fcgi/specification.hpp +++ b/boost/cgi/fcgi/specification.hpp @@ -100,7 +100,7 @@ BOOST_CGI_NAMESPACE_BEGIN unsigned char paddingLength_; unsigned char reserved_; } impl; - + public: typedef boost::asio::const_buffer const_buffers_type; typedef boost::asio::mutable_buffer mutable_buffers_type; @@ -115,7 +115,7 @@ BOOST_CGI_NAMESPACE_BEGIN { reset(t, id, len); } - + mutable_buffers_type data() { return boost::asio::buffer( @@ -123,7 +123,7 @@ BOOST_CGI_NAMESPACE_BEGIN , sizeof(impl)); } - const_buffers_type data() const + const_buffers_type data() const { return boost::asio::buffer( static_cast(&impl) @@ -266,8 +266,8 @@ BOOST_CGI_NAMESPACE_BEGIN memset(impl.reserved_, 0, sizeof(impl.reserved_)); } - - const_buffers_type data() const + + const_buffers_type data() const { return boost::asio::buffer( static_cast(&impl) @@ -351,10 +351,10 @@ BOOST_CGI_NAMESPACE_BEGIN impl.body_.reset( (unsigned char)type ); // not sure why this is C-style } }; - + #endif - } // namespace detail - + } // namespace detail + namespace specification { /// Define the FastCGI spec using types. @@ -369,26 +369,26 @@ BOOST_CGI_NAMESPACE_BEGIN struct header_length : boost::mpl::int_<8> {}; - + struct listensock_fileno : boost::mpl::int_<0> {}; static const unsigned char keep_connection = 1; - + struct null_request_id : boost::mpl::int_<0> {}; template int get_version(Array& a) { return static_cast(a[0]); } - + template spec_detail::request_types get_type(Array& a) { return static_cast(a[1]); } - + template boost::uint16_t get_request_id(Array& a) { @@ -449,7 +449,7 @@ BOOST_CGI_NAMESPACE_BEGIN } } }; - + typedef spec_detail::Header header; typedef spec_detail::EndRequestBody end_request_body; @@ -460,12 +460,12 @@ BOOST_CGI_NAMESPACE_BEGIN { typedef boost::mpl::int_<8> size; }; - + typedef boost::array< unsigned char , header_length::value > buffer_type; - + buffer_type impl; begin_request(buffer_type& buf) @@ -499,7 +499,7 @@ BOOST_CGI_NAMESPACE_BEGIN return a[2]; } }; - + struct stdout_header : spec_detail::Header { @@ -536,7 +536,7 @@ BOOST_CGI_NAMESPACE_BEGIN , end_request_body(app_status, proc_status) { } - + void reset ( int request_id diff --git a/boost/cgi/fcgi/win32_acceptor_service_impl.hpp b/boost/cgi/fcgi/win32_acceptor_service_impl.hpp index eceea36..dea813b 100644 --- a/boost/cgi/fcgi/win32_acceptor_service_impl.hpp +++ b/boost/cgi/fcgi/win32_acceptor_service_impl.hpp @@ -164,7 +164,7 @@ BOOST_CGI_NAMESPACE_BEGIN * acceptor_service_impl acceptor_service_impl_; // etc... * * Note: If the protocol is an asynchronous protocol, which means it - * requires access to a boost::asio::io_service instance, then this + * requires access to a boost::asio::io_context instance, then this * class becomes a model of the Service concept (**LINK**) and must * only use the constructor which takes a ProtocolService (**LINK**). * If the protocol isn't async then the class can be used without a @@ -215,7 +215,7 @@ BOOST_CGI_NAMESPACE_BEGIN implementation_type() : async_accepts_(0) {} }; - explicit win32_acceptor_service_impl(::BOOST_CGI_NAMESPACE::common::io_service& ios) + explicit win32_acceptor_service_impl(::BOOST_CGI_NAMESPACE::common::io_context& ios) : detail::service_base< ::BOOST_CGI_NAMESPACE::fcgi::win32_acceptor_service_impl >(ios) , acceptor_service_(boost::asio::use_service(ios)) , strand_(ios) @@ -520,7 +520,7 @@ BOOST_CGI_NAMESPACE_BEGIN if (transport_ == detail::transport::pipe) strand_.post(detail::accept_handler(*this, impl, request, handler)); else // transport_ == detail::transport::socket - this->io_service().post(detail::accept_handler(*this, impl, request, handler)); + this->io_context().post(detail::accept_handler(*this, impl, request, handler)); } /// Close the acceptor (not implemented yet). @@ -601,7 +601,7 @@ BOOST_CGI_NAMESPACE_BEGIN public: /// The underlying socket acceptor service. acceptor_service_type& acceptor_service_; - boost::asio::io_service::strand strand_; + boost::asio::io_context::strand strand_; detail::transport::type transport_; HANDLE listen_handle_; bool is_cgi_; diff --git a/boost/cgi/fwd/basic_protocol_service_fwd.hpp b/boost/cgi/fwd/basic_protocol_service_fwd.hpp index 5f852a4..6d25e20 100644 --- a/boost/cgi/fwd/basic_protocol_service_fwd.hpp +++ b/boost/cgi/fwd/basic_protocol_service_fwd.hpp @@ -20,7 +20,7 @@ BOOST_CGI_NAMESPACE_BEGIN template< typename Protocol, - typename IoServiceProvider = common::io_service_provider<> + typename IoContextProvider = common::io_context_provider<> > class basic_protocol_service; diff --git a/boost/cgi/fwd/io_service_provider_fwd.hpp b/boost/cgi/fwd/io_service_provider_fwd.hpp index d1c13ec..ea1ec0e 100644 --- a/boost/cgi/fwd/io_service_provider_fwd.hpp +++ b/boost/cgi/fwd/io_service_provider_fwd.hpp @@ -19,7 +19,7 @@ BOOST_CGI_NAMESPACE_BEGIN namespace common { template - class io_service_provider; + class io_context_provider; } // namespace common BOOST_CGI_NAMESPACE_END diff --git a/boost/cgi/fwd/request_service_fwd.hpp b/boost/cgi/fwd/request_service_fwd.hpp index f129d3d..3b838b5 100644 --- a/boost/cgi/fwd/request_service_fwd.hpp +++ b/boost/cgi/fwd/request_service_fwd.hpp @@ -15,7 +15,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// The generic service class for basic_request<>s /** * Note: If the protocol is an asynchronous protocol, which means it requires - * access to a boost::asio::io_service instance, then this class becomes a + * access to a boost::asio::io_context instance, then this class becomes a * model of the Service concept (**LINK**) and must only use the constructor * which takes a ProtocolService (**LINK**). If the protocol isn't async then * the class can be used without a ProtocolService. diff --git a/boost/cgi/impl/basic_request.ipp b/boost/cgi/impl/basic_request.ipp index dd5776e..0315901 100644 --- a/boost/cgi/impl/basic_request.ipp +++ b/boost/cgi/impl/basic_request.ipp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include /////////////////////////////////////////////////////////// @@ -64,7 +64,7 @@ BOOST_CGI_NAMESPACE_BEGIN // Throws. template basic_request:: basic_request(implementation_type& impl) - : basic_io_object(impl.service_->io_service()) + : basic_io_object(impl.service_->io_context()) { set_protocol_service(*impl.service_); boost::system::error_code ec; @@ -77,7 +77,7 @@ BOOST_CGI_NAMESPACE_BEGIN // Won't throw. template basic_request:: basic_request(implementation_type& impl, boost::system::error_code& ec) - : basic_io_object(impl.service_->io_service()) + : basic_io_object(impl.service_->io_context()) { set_protocol_service(*impl.service_); this->service.begin_request_helper(this->implementation diff --git a/boost/cgi/impl/fcgi_request_service.ipp b/boost/cgi/impl/fcgi_request_service.ipp index 590d6f3..f18a29f 100644 --- a/boost/cgi/impl/fcgi_request_service.ipp +++ b/boost/cgi/impl/fcgi_request_service.ipp @@ -492,7 +492,7 @@ BOOST_CGI_NAMESPACE_BEGIN { // clear the header first (might be unneccesary). impl.header_buf_ = header_buffer_type(); - this->get_io_service().poll(); + this->get_io_context().poll(); async_read(*impl.client_.connection(), buffer(impl.header_buf_), [&](boost::system::error_code const &e, std::size_t bytes_transfered __attribute__((__unused__))) -> void { @@ -501,9 +501,9 @@ BOOST_CGI_NAMESPACE_BEGIN while (impl.header_buf_ == header_buffer_type() && !ec) { - this->get_io_service().run_one(); - if (this->get_io_service().stopped()) - this->get_io_service().reset(); + this->get_io_context().run_one(); + if (this->get_io_context().stopped()) + this->get_io_context().reset(); } return ec; @@ -524,7 +524,8 @@ BOOST_CGI_NAMESPACE_BEGIN boost::asio::async_read( *impl.client_.connection(), buffer(impl.header_buf_) , boost::asio::transfer_all() - , strand_.wrap( + , boost::asio::bind_executor( + strand_, boost::bind(&self_type::handle_read_header, this, boost::ref(impl), opts, handler, boost::asio::placeholders::error, @@ -800,19 +801,19 @@ BOOST_CGI_NAMESPACE_BEGIN switch(fcgi::spec::get_type(impl.header_buf_)) { case 1: process_begin_request(impl, fcgi::spec::get_request_id(impl.header_buf_) - , boost::asio::buffer_cast(buf) + , buf.data() , boost::asio::buffer_size(buf), ec); break; case 2: process_abort_request(impl, fcgi::spec::get_request_id(impl.header_buf_) - , boost::asio::buffer_cast(buf) + , buf.data() , boost::asio::buffer_size(buf), ec); break; case 4: process_params(impl, fcgi::spec::get_request_id(impl.header_buf_) - , boost::asio::buffer_cast(buf) + , buf.data() , boost::asio::buffer_size(buf), ec); break; case 5: process_stdin(impl, fcgi::spec::get_request_id(impl.header_buf_) - , boost::asio::buffer_cast(buf) + , buf.data() , boost::asio::buffer_size(buf), ec); break; default: break; diff --git a/boost/cgi/impl/response.ipp b/boost/cgi/impl/response.ipp index bfce736..24868fc 100644 --- a/boost/cgi/impl/response.ipp +++ b/boost/cgi/impl/response.ipp @@ -80,7 +80,7 @@ BOOST_CGI_NAMESPACE_BEGIN , headers_terminated_(false) , charset_("ISO-8859-1") { - //ostream_.openmode = + //ostream_.openmode = } /// Construct with a particular buffer @@ -92,7 +92,7 @@ BOOST_CGI_NAMESPACE_BEGIN basic_response::basic_response(common::streambuf* buf, http::status_code sc) #if BOOST_WINDOWS - : ostream_(buf, std::ios::out | std::ios::binary) + : ostream_(buf, std::ios::out | std::ios::binary) #else : ostream_(buf) #endif // defined (BOOST_WINDOWS) @@ -106,7 +106,7 @@ BOOST_CGI_NAMESPACE_BEGIN template BOOST_CGI_INLINE basic_response::~basic_response() { - } + } /// Clear the response buffer. template BOOST_CGI_INLINE @@ -130,7 +130,7 @@ BOOST_CGI_NAMESPACE_BEGIN void basic_response::reset() { clear(); - ostream_.flush(); + ostream_.flush(); buffer_->consume(buffer_->size()); headers_terminated_ = false; } @@ -178,7 +178,7 @@ BOOST_CGI_NAMESPACE_BEGIN flush(sws, ec); detail::throw_error(ec); } - + /// Synchronously flush the data via the supplied request /** * This call uses error_code semantics. ie. ec is set if an error occurs. @@ -276,7 +276,7 @@ BOOST_CGI_NAMESPACE_BEGIN template BOOST_CGI_INLINE void basic_response::async_send(AsyncWriteStream& aws, Handler handler) { - aws.io_service().post( + aws.io_context().post( boost::bind(&basic_response::do_async_send, aws, handler) ); } @@ -315,7 +315,7 @@ BOOST_CGI_NAMESPACE_BEGIN /// Get the status code associated with the response. template BOOST_CGI_INLINE - http::status_code + http::status_code basic_response::status() const { return http_status_; @@ -336,7 +336,7 @@ BOOST_CGI_NAMESPACE_BEGIN } /// Get the response as a string. - template BOOST_CGI_INLINE + template BOOST_CGI_INLINE typename basic_response::string_type basic_response::str(bool include_header) const { @@ -352,11 +352,11 @@ BOOST_CGI_NAMESPACE_BEGIN body += *iter; } } - + body += string_type( - boost::asio::buffer_cast(buffer_->data()), - boost::asio::buffer_size(buffer_->data())); - + buffer_->data(), + buffer_->size()); + return body; } @@ -447,12 +447,12 @@ BOOST_CGI_NAMESPACE_BEGIN template BOOST_CGI_INLINE typename basic_response::ostream_type& basic_response::ostream() { return ostream_; } - + /// Get the ostream containing the response body. template BOOST_CGI_INLINE std::vector::string_type>& basic_response::headers() { return headers_; } - + // Send the response headers and mark that they've been sent. template template BOOST_CGI_INLINE @@ -481,7 +481,7 @@ BOOST_CGI_NAMESPACE_BEGIN { boost::cgi::common::name type(iter->substr(0, 12).c_str()); if (type == "Content-type") - iter->insert(iter->length()-2, "; charset=" + charset_); + iter->insert(iter->length()-2, "; charset=" + charset_); //{ Construct a ConstBufferSequence out of the headers we have. headers.push_back(common::buffer(*iter)); @@ -492,7 +492,7 @@ BOOST_CGI_NAMESPACE_BEGIN } template BOOST_CGI_INLINE - BOOST_CGI_NAMESPACE::common::basic_response& + BOOST_CGI_NAMESPACE::common::basic_response& operator<< (BOOST_CGI_NAMESPACE::common::basic_response& resp , BOOST_CGI_NAMESPACE::common::basic_cookie const& ck) { diff --git a/boost/cgi/import/io_service.hpp b/boost/cgi/import/io_service.hpp index 3b5a876..acb686d 100644 --- a/boost/cgi/import/io_service.hpp +++ b/boost/cgi/import/io_service.hpp @@ -18,7 +18,7 @@ BOOST_CGI_NAMESPACE_BEGIN namespace common { - using boost::asio::io_service; + using boost::asio::io_context; } // namespace common BOOST_CGI_NAMESPACE_END diff --git a/boost/cgi/scgi/request_acceptor_service.hpp b/boost/cgi/scgi/request_acceptor_service.hpp index 2bb8860..8d241c0 100644 --- a/boost/cgi/scgi/request_acceptor_service.hpp +++ b/boost/cgi/scgi/request_acceptor_service.hpp @@ -73,7 +73,7 @@ BOOST_CGI_NAMESPACE_BEGIN endpoint_type endpoint_; }; - explicit scgi_request_acceptor_service(::BOOST_CGI_NAMESPACE::common::io_service& ios) + explicit scgi_request_acceptor_service(::BOOST_CGI_NAMESPACE::common::io_context& ios) : detail::service_base< ::BOOST_CGI_NAMESPACE::scgi_request_acceptor_service >(ios) , acceptor_service_(boost::asio::use_service(ios)) , strand_(ios) @@ -322,7 +322,7 @@ BOOST_CGI_NAMESPACE_BEGIN public: /// The underlying socket acceptor service. acceptor_service_type& acceptor_service_; - boost::asio::io_service::strand strand_; + boost::asio::io_context::strand strand_; }; //} // namespace scgi diff --git a/boost/cgi/scgi/request_service.hpp b/boost/cgi/scgi/request_service.hpp index 4bc23cf..19c439e 100644 --- a/boost/cgi/scgi/request_service.hpp +++ b/boost/cgi/scgi/request_service.hpp @@ -110,7 +110,7 @@ BOOST_CGI_NAMESPACE_BEGIN }; - scgi_request_service(::BOOST_CGI_NAMESPACE::common::io_service& ios) + scgi_request_service(::BOOST_CGI_NAMESPACE::common::io_context& ios) : detail::service_base >(ios) , strand_(ios) { @@ -123,7 +123,7 @@ BOOST_CGI_NAMESPACE_BEGIN void construct(implementation_type& impl) { impl.client_.set_connection( - implementation_type::connection_type::create(this->get_io_service()) + implementation_type::connection_type::create(this->get_io_context()) ); } @@ -197,7 +197,7 @@ BOOST_CGI_NAMESPACE_BEGIN ); private: - boost::asio::io_service::strand strand_; + boost::asio::io_context::strand strand_; }; } // namespace scgi diff --git a/boost/cgi/scgi/request_service.ipp b/boost/cgi/scgi/request_service.ipp index 7850edc..0231201 100644 --- a/boost/cgi/scgi/request_service.ipp +++ b/boost/cgi/scgi/request_service.ipp @@ -26,7 +26,7 @@ #include "boost/cgi/common/parse_options.hpp" #include "boost/cgi/http/status_code.hpp" #include "boost/cgi/import/read.hpp" -#include "boost/cgi/import/io_service.hpp" +#include "boost/cgi/import/io_context.hpp" #include "boost/cgi/detail/service_base.hpp" #include "boost/cgi/detail/throw_error.hpp" #include "boost/cgi/config.hpp" From 262a226c369885ddf79176f64d0d322407bc9ae0 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Tue, 20 Feb 2018 00:28:22 +0000 Subject: [PATCH 10/12] cast buffer data to the correct pointer type --- boost/cgi/impl/fcgi_request_service.ipp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boost/cgi/impl/fcgi_request_service.ipp b/boost/cgi/impl/fcgi_request_service.ipp index f18a29f..a08aa97 100644 --- a/boost/cgi/impl/fcgi_request_service.ipp +++ b/boost/cgi/impl/fcgi_request_service.ipp @@ -801,19 +801,19 @@ BOOST_CGI_NAMESPACE_BEGIN switch(fcgi::spec::get_type(impl.header_buf_)) { case 1: process_begin_request(impl, fcgi::spec::get_request_id(impl.header_buf_) - , buf.data() + , static_cast(buf.data()) , boost::asio::buffer_size(buf), ec); break; case 2: process_abort_request(impl, fcgi::spec::get_request_id(impl.header_buf_) - , buf.data() + , static_cast(buf.data()) , boost::asio::buffer_size(buf), ec); break; case 4: process_params(impl, fcgi::spec::get_request_id(impl.header_buf_) - , buf.data() + , static_cast(buf.data()) , boost::asio::buffer_size(buf), ec); break; case 5: process_stdin(impl, fcgi::spec::get_request_id(impl.header_buf_) - , buf.data() + , static_cast(buf.data()) , boost::asio::buffer_size(buf), ec); break; default: break; From 3124b78deee897bb03925649cfe0c03a7a2e2129 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Tue, 20 Feb 2018 01:44:11 +0000 Subject: [PATCH 11/12] more asio deprecation updates --- boost/cgi/common/basic_protocol_service.hpp | 6 ++++-- boost/cgi/fcgi/acceptor_service_impl.hpp | 16 +++++++--------- boost/cgi/impl/fcgi_request_service.ipp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/boost/cgi/common/basic_protocol_service.hpp b/boost/cgi/common/basic_protocol_service.hpp index 77e8963..d9e0e12 100644 --- a/boost/cgi/common/basic_protocol_service.hpp +++ b/boost/cgi/common/basic_protocol_service.hpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include /////////////////////////////////////////////////////////// #include "boost/cgi/config.hpp" #include "boost/cgi/common/protocol_traits.hpp" @@ -114,14 +116,14 @@ BOOST_CGI_NAMESPACE_BEGIN template void post(Handler handler) { - ios_provider_.get_io_context().post(handler); + boost::asio::post(ios_provider_.get_io_context(), handler); } /// Dispatch a handler through an available io_context template void dispatch(Handler handler) { - ios_provider_.get_io_context().dispatch(handler); + boost::asio::dispatch(ios_provider_.get_io_context(), handler); } private: diff --git a/boost/cgi/fcgi/acceptor_service_impl.hpp b/boost/cgi/fcgi/acceptor_service_impl.hpp index d66b900..7d4e8c4 100644 --- a/boost/cgi/fcgi/acceptor_service_impl.hpp +++ b/boost/cgi/fcgi/acceptor_service_impl.hpp @@ -124,8 +124,8 @@ BOOST_CGI_NAMESPACE_BEGIN { // I've never got the default initialisation working on Windows... #if ! defined(BOOST_WINDOWS) - return acceptor_service_.assign(impl.acceptor_, boost::asio::ip::tcp::v4() - , 0, ec); + acceptor_service_.assign(impl.acceptor_, boost::asio::ip::tcp::v4() + , 0, ec); #endif return ec; } @@ -256,7 +256,7 @@ BOOST_CGI_NAMESPACE_BEGIN } } - void handle_accept( + void handle_accept( implementation_type& impl, request_ptr new_request, accept_handler_type handler, const boost::system::error_code& ec __attribute__((__unused__)) ) @@ -275,12 +275,10 @@ BOOST_CGI_NAMESPACE_BEGIN void async_accept(implementation_type& impl , accept_handler_type handler) { - //impl.service_->post( - strand_.post( - boost::bind(&self_type::do_accept, - this, boost::ref(impl), handler) - ); - //); + boost::asio::post(strand_, + boost::bind(&self_type::do_accept, + this, boost::ref(impl), handler) + ); } int accept(implementation_type& impl, accept_handler_type handler diff --git a/boost/cgi/impl/fcgi_request_service.ipp b/boost/cgi/impl/fcgi_request_service.ipp index a08aa97..d9c4cfc 100644 --- a/boost/cgi/impl/fcgi_request_service.ipp +++ b/boost/cgi/impl/fcgi_request_service.ipp @@ -503,7 +503,7 @@ BOOST_CGI_NAMESPACE_BEGIN { this->get_io_context().run_one(); if (this->get_io_context().stopped()) - this->get_io_context().reset(); + this->get_io_context().restart(); } return ec; From 83d955ed4710e878cfa3158f3bbf07935234c1a4 Mon Sep 17 00:00:00 2001 From: SlowRiot Date: Mon, 21 Jan 2019 17:12:38 +0000 Subject: [PATCH 12/12] accept a const ConstBufferSequence reference, for compatibility with latest boost asio --- boost/cgi/connections/shareable_tcp_socket.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/boost/cgi/connections/shareable_tcp_socket.hpp b/boost/cgi/connections/shareable_tcp_socket.hpp index 6b05e9a..bd60c39 100644 --- a/boost/cgi/connections/shareable_tcp_socket.hpp +++ b/boost/cgi/connections/shareable_tcp_socket.hpp @@ -34,7 +34,7 @@ BOOST_CGI_NAMESPACE_BEGIN * I'm planning on making this class a more FastCGI-specific one since a * rereading of the FastCGI spec (ie. 'Managing request IDs') made me * realise that IDs are connection specific, not just application specific. - * + * * IOW when checking to see if a particular request id exists, rather than * having to check a table in the protocol_service (which may imply explicit * mutex use), we can just check a local array of values. Good good. @@ -113,7 +113,7 @@ BOOST_CGI_NAMESPACE_BEGIN { return //static_cast( pointer(new basic_connection(ios)); - } + } template std::size_t read_some(const MutableBufferSequence& buf) @@ -135,13 +135,13 @@ BOOST_CGI_NAMESPACE_BEGIN } template - std::size_t write_some(ConstBufferSequence& buf) + std::size_t write_some(ConstBufferSequence const& buf) { return sock_.write_some(buf); } template - std::size_t write_some(ConstBufferSequence& buf + std::size_t write_some(ConstBufferSequence const& buf , boost::system::error_code& ec) { return sock_.write_some(buf, ec); @@ -152,7 +152,7 @@ BOOST_CGI_NAMESPACE_BEGIN { sock_.async_write_some(buf, handler); } - + next_layer_type& next_layer() { @@ -190,11 +190,11 @@ BOOST_CGI_NAMESPACE_BEGIN //boost::system::error_code // multiplex(RequestImpl& impl, boost::system::error_code& ec) //{ - // + // // return ec; //} private: - + bool locked_; next_layer_type sock_; mutex_type mutex_;