From 4e7de5b5f0e32d1183e2a0490d65e4e01490d942 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 25 Jun 2015 14:31:03 -0700 Subject: [PATCH] rgw: error out if frontend did not send all data 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 (cherry picked from commit daa679c3dd3770a6d5421e2cc9a36924f4550439) --- src/rgw/rgw_civetweb.cc | 11 ++++++++--- src/rgw/rgw_client_io.cc | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc index 7f246d15c26da..5c15bcfe91b28 100644 --- a/src/rgw/rgw_civetweb.cc +++ b/src/rgw/rgw_civetweb.cc @@ -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), diff --git a/src/rgw/rgw_client_io.cc b/src/rgw/rgw_client_io.cc index 193f44e96e001..32d99dcfb2b7e 100644 --- a/src/rgw/rgw_client_io.cc +++ b/src/rgw/rgw_client_io.cc @@ -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; } -- 2.39.5