]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: error out if frontend did not send all data 5234/head
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 25 Jun 2015 21:31:03 +0000 (14:31 -0700)
committerNathan Cutler <ncutler@suse.com>
Tue, 14 Jul 2015 10:09:31 +0000 (12:09 +0200)
Fixes: #11851
The civetweb mg_write() doesn't return error when it can't flush all data
to the user, it just sends the total number of bytes written. Modified the
client io to return total number of bytes and return an error if didn't
send anything.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit daa679c3dd3770a6d5421e2cc9a36924f4550439)

src/rgw/rgw_civetweb.cc
src/rgw/rgw_client_io.cc

index 7f246d15c26da9af0bae8641fd93141dd0d795aa..5c15bcfe91b28692124a9f76141774e63297948f 100644 (file)
@@ -11,13 +11,18 @@ int RGWMongoose::write_data(const char *buf, int len)
 {
   if (!header_done) {
     header_data.append(buf, len);
-    return 0;
+    return len;
   }
   if (!sent_header) {
     data.append(buf, len);
-    return 0;
+    return len;
+  }
+  int r = mg_write(conn, buf, len);
+  if (r == 0) {
+    /* didn't send anything, error out */
+    return -EIO;
   }
-  return mg_write(conn, buf, len);
+  return r;
 }
 
 RGWMongoose::RGWMongoose(mg_connection *_conn, int _port) : conn(_conn), port(_port), header_done(false), sent_header(false), has_content_length(false),
index 193f44e96e001c43aa5e67eeda8deb2b19cafdbe..32d99dcfb2b7eef89314586f76bb3d892de68227 100644 (file)
@@ -54,7 +54,12 @@ int RGWClientIO::write(const char *buf, int len)
     return ret;
 
   if (account)
-    bytes_sent += len;
+    bytes_sent += ret;
+
+  if (ret < len) {
+    /* sent less than tried to send, error out */
+    return -EIO;
+  }
 
   return 0;
 }