]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: error out if frontend did not send all data 5081/head
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 25 Jun 2015 21:31:03 +0000 (14:31 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 25 Jun 2015 21:35:14 +0000 (14:35 -0700)
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>
src/rgw/rgw_civetweb.cc
src/rgw/rgw_client_io.cc

index 1495e92d4741f3cd057b4c3c127dbf185516924e..827709b993b342cfb5613b43231589d080607588 100644 (file)
@@ -13,13 +13,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 5e8edbf311236708e46c6cbaa461fb2390d60f03..1f8b803a3d405e65c483296ffe6b47caaa90a781 100644 (file)
@@ -56,7 +56,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;
 }