]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw:[bug] civetweb mg_write with offset. 32821/head
authorGabe Lee <ligangbin117@163.com>
Fri, 8 Nov 2019 02:00:11 +0000 (10:00 +0800)
committerNathan Cutler <ncutler@suse.com>
Fri, 24 Jan 2020 14:20:46 +0000 (15:20 +0100)
data consistency error casued by rgw sent timeout.
Incomplete data transmission and incorrect data re-transmission

Signed-off-by: 李纲彬82225 <82225@sangfor.com>
(cherry picked from commit d9fccedda90ff889fbaaa35ebacf3f3b4574ea09)

src/rgw/rgw_civetweb.cc

index 1252835c6241d26ce22d7a4a150e5537a357533a..f0f8ef5d1c0d6cc04ac7359f8128abc4bcac366c 100644 (file)
 
 size_t RGWCivetWeb::write_data(const char *buf, const size_t len)
 {
+  size_t off = 0;
   auto to_sent = len;
   while (to_sent) {
-    const int ret = mg_write(conn, buf, len);
+    const int ret = mg_write(conn, buf + off, to_sent);
     if (ret < 0 || ! ret) {
       /* According to the documentation of mg_write() it always returns -1 on
        * error. The details aren't available, so we will just throw EIO. Same
        * goes to 0 that is associated with writing to a closed connection. */
       throw rgw::io::Exception(EIO, std::system_category());
     } else {
+      off += static_cast<size_t>(ret);
       to_sent -= static_cast<size_t>(ret);
     }
   }