]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/beast: StreamIO remembers connection errors for graceful shutdown 49841/head
authorCasey Bodley <cbodley@redhat.com>
Wed, 8 Feb 2023 17:58:10 +0000 (12:58 -0500)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Fri, 3 Mar 2023 03:14:51 +0000 (10:14 +0700)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 525899d4608203ea4236a816a78cf871cadceea6)

src/rgw/rgw_asio_frontend.cc

index c772a0299b12cafadf7ff4f32630b3b07e7af2b4..be5af0a70d396f7f70843ebbe6857ff3781e00bc 100644 (file)
@@ -69,6 +69,7 @@ class StreamIO : public rgw::asio::ClientIO {
   timeout_timer& timeout;
   yield_context yield;
   parse_buffer& buffer;
+  boost::system::error_code fatal_ec;
  public:
   StreamIO(CephContext *cct, Stream& stream, timeout_timer& timeout,
            rgw::asio::parser_type& parser, yield_context yield,
@@ -80,6 +81,8 @@ class StreamIO : public rgw::asio::ClientIO {
         buffer(buffer)
   {}
 
+  boost::system::error_code get_fatal_error_code() const { return fatal_ec; }
+
   size_t write_data(const char* buf, size_t len) override {
     boost::system::error_code ec;
     timeout.start();
@@ -92,6 +95,9 @@ class StreamIO : public rgw::asio::ClientIO {
         boost::system::error_code ec_ignored;
         stream.lowest_layer().shutdown(tcp_socket::shutdown_both, ec_ignored);
       }
+      if (!fatal_ec) {
+        fatal_ec = ec;
+      }
       throw rgw::io::Exception(ec.value(), std::system_category());
     }
     return bytes;
@@ -113,6 +119,9 @@ class StreamIO : public rgw::asio::ClientIO {
       }
       if (ec) {
         ldout(cct, 4) << "failed to read body: " << ec.message() << dendl;
+        if (!fatal_ec) {
+          fatal_ec = ec;
+        }
         throw rgw::io::Exception(ec.value(), std::system_category());
       }
     }
@@ -281,6 +290,13 @@ void handle_connection(boost::asio::io_context& context,
             << latency << dendl;
       }
 
+      // process_request() can't distinguish between connection errors and
+      // http/s3 errors, so check StreamIO for fatal connection errors
+      ec = real_client.get_fatal_error_code();
+      if (ec) {
+        return;
+      }
+
       if (real_client.sent_100_continue()) {
         expect_continue = false;
       }