From: Gabe Lee Date: Fri, 8 Nov 2019 02:00:11 +0000 (+0800) Subject: rgw:[bug] civetweb mg_write with offset. X-Git-Tag: v15.1.0~281^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d9fccedda90ff889fbaaa35ebacf3f3b4574ea09;p=ceph.git rgw:[bug] civetweb mg_write with offset. data consistency error casued by rgw sent timeout. Incomplete data transmission and incorrect data re-transmission Signed-off-by: 李纲彬82225 <82225@sangfor.com> --- diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc index 27a02f6771d3..99e61d356689 100644 --- a/src/rgw/rgw_civetweb.cc +++ b/src/rgw/rgw_civetweb.cc @@ -14,15 +14,17 @@ 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(ret); to_sent -= static_cast(ret); } }