]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw:[bug] civetweb mg_write with offset. 30257/head
authorGabe Lee <ligangbin117@163.com>
Fri, 8 Nov 2019 02:00:11 +0000 (10:00 +0800)
committerGabe Lee <ligangbin117@163.com>
Fri, 8 Nov 2019 02:00:11 +0000 (10:00 +0800)
data consistency error casued by rgw sent timeout.
Incomplete data transmission and incorrect data re-transmission

Signed-off-by: 李纲彬82225 <82225@sangfor.com>
src/rgw/rgw_civetweb.cc

index 27a02f6771d3e9c8598b19b7b1e179817ec8f48a..99e61d356689b5f0a187775d1273598ad0ec0679 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);
     }
   }