@@ -114,17 +114,17 @@ class StreamIO : public rgw::asio::ClientIO {
114114 CephContext* const cct;
115115 Stream& stream;
116116 timeout_timer& timeout;
117- boost::asio::yield_context yield ;
117+ optional_yield y ;
118118 parse_buffer& buffer;
119119 boost::system::error_code fatal_ec;
120120 public:
121121 StreamIO (CephContext *cct, Stream& stream, timeout_timer& timeout,
122- rgw::asio::parser_type& parser, boost::asio::yield_context yield ,
122+ rgw::asio::parser_type& parser, optional_yield y ,
123123 parse_buffer& buffer, bool is_ssl,
124124 const tcp::endpoint& local_endpoint,
125125 const tcp::endpoint& remote_endpoint)
126126 : ClientIO(parser, is_ssl, local_endpoint, remote_endpoint),
127- cct (cct), stream(stream), timeout(timeout), yield(yield ),
127+ cct (cct), stream(stream), timeout(timeout), y(y ),
128128 buffer(buffer)
129129 {}
130130
@@ -133,8 +133,14 @@ class StreamIO : public rgw::asio::ClientIO {
133133 size_t write_data (const char * buf, size_t len) override {
134134 boost::system::error_code ec;
135135 timeout.start ();
136- auto bytes = boost::asio::async_write (stream, boost::asio::buffer (buf, len),
137- yield[ec]);
136+ size_t bytes = 0 ;
137+ if (y) {
138+ boost::asio::yield_context& yield = y.get_yield_context ();
139+ bytes = boost::asio::async_write (stream, boost::asio::buffer (buf, len),
140+ yield[ec]);
141+ } else {
142+ bytes = boost::asio::write (stream, boost::asio::buffer (buf, len), ec);
143+ }
138144 timeout.cancel ();
139145 if (ec) {
140146 ldout (cct, 4 ) << " write_data failed: " << ec.message () << dendl;
@@ -159,7 +165,12 @@ class StreamIO : public rgw::asio::ClientIO {
159165 while (body_remaining.size && !parser.is_done ()) {
160166 boost::system::error_code ec;
161167 timeout.start ();
162- http::async_read_some (stream, buffer, parser, yield[ec]);
168+ if (y) {
169+ boost::asio::yield_context& yield = y.get_yield_context ();
170+ http::async_read_some (stream, buffer, parser, yield[ec]);
171+ } else {
172+ http::read_some (stream, buffer, parser, ec);
173+ }
163174 timeout.cancel ();
164175 if (ec == http::error::need_buffer) {
165176 break ;
@@ -315,7 +326,11 @@ void handle_connection(boost::asio::io_context& context,
315326 return ;
316327 }
317328
318- StreamIO real_client{cct, stream, timeout, parser, yield, buffer,
329+ optional_yield y = null_yield;
330+ if (cct->_conf ->rgw_beast_enable_async ) {
331+ y = optional_yield{yield};
332+ }
333+ StreamIO real_client{cct, stream, timeout, parser, y, buffer,
319334 is_ssl, local_endpoint, remote_endpoint};
320335
321336 auto real_client_io = rgw::io::add_reordering (
@@ -334,10 +349,6 @@ void handle_connection(boost::asio::io_context& context,
334349 client_env.set (" SSL_CIPHER" , ssl_cipher);
335350 client_env.set (" TLS_VERSION" , tls_version);
336351 }
337- optional_yield y = null_yield;
338- if (cct->_conf ->rgw_beast_enable_async ) {
339- y = optional_yield{yield};
340- }
341352 int http_ret = 0 ;
342353 string user = " -" ;
343354 const auto started = ceph::coarse_real_clock::now ();
0 commit comments