]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/beast: StreamIO remembers connection errors for graceful shutdown 50239/head
authorCasey Bodley <cbodley@redhat.com>
Wed, 8 Feb 2023 17:58:10 +0000 (12:58 -0500)
committerCasey Bodley <cbodley@redhat.com>
Thu, 23 Feb 2023 19:03:04 +0000 (14:03 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 525899d4608203ea4236a816a78cf871cadceea6)

src/rgw/rgw_asio_frontend.cc

index 532ae0183d18c91d56452607fd537d9f0e44d2f9..917f0a7efaf65bb675af0cc8f0d5613efb898dfa 100644 (file)
@@ -72,6 +72,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,
@@ -83,6 +84,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();
@@ -95,6 +98,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;
@@ -116,6 +122,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());
       }
     }
@@ -286,6 +295,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;
       }