]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't continue processing of GET request on error
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 22 Oct 2012 20:16:59 +0000 (13:16 -0700)
committerSage Weil <sage@inktank.com>
Mon, 22 Oct 2012 20:37:06 +0000 (13:37 -0700)
Fixes #3381
We continued processing requests long after the client
has died. This fix appliese to both s3 and swift.

backport: argonaut
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_common.h
src/rgw/rgw_op.cc
src/rgw/rgw_rest.cc
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_swift.cc

index 22f69f45ac7726b9cc48a34461a157b901878a90..1841d268e61974afad1e2aa6017660687a106128 100644 (file)
@@ -83,11 +83,7 @@ using ceph::crypto::MD5;
    } \
 } while (0)
 
-#define CGI_PutStr(state, buf, len) do { \
-  FCGX_PutStr(buf, len, state->fcgx->out); \
-  if (state->header_ended) \
-    state->bytes_sent += len; \
-} while (0)
+extern int CGI_PutStr(struct req_state *state, const char *buf, uint64_t len);
 
 #define CGI_GetStr(state, buf, buf_len, olen) do { \
   olen = FCGX_GetStr(buf, buf_len, state->fcgx->in); \
index 35b5f5d79f6958c61c59ca5402c1ec51b522ba28..c092a295ec9acc9eab77e6ee86ce17b175f5932a 100644 (file)
@@ -353,8 +353,13 @@ void RGWGetObj::execute()
 
     perfcounter->finc(l_rgw_get_lat,
                      (ceph_clock_now(s->cct) - start_time));
-    send_response(bl);
+    ret = send_response(bl);
     bl.clear();
+    if (ret < 0) {
+      dout(0) << "NOTICE: failed to send response to client" << dendl;
+      goto done;
+    }
+
     start_time = ceph_clock_now(s->cct);
   }
 
index fb55f3477b69fd4a467c74d78f915308be970bf4..10f74e79de80cbb935592e0052b3ceb2034bc9a7 100644 (file)
@@ -1006,3 +1006,15 @@ void RGWHandler_REST::put_op(RGWOp *op)
   delete op;
 }
 
+int CGI_PutStr(struct req_state *state, const char *buf, uint64_t len)
+{
+  int r = FCGX_PutStr(buf, len, state->fcgx->out);
+  if (r < 0)
+    return r;
+
+  if (state->header_ended)
+    state->bytes_sent += len;
+
+  return 0;
+}
+
index 968b329d2ef27eee8e3385256bb96ae9652d86f4..10c615b9e807eefcfdafb54f50ffc26eb0143918 100644 (file)
@@ -113,7 +113,9 @@ done:
 
 send_data:
   if (get_data && !orig_ret) {
-    CGI_PutStr(s, bl.c_str(), len);
+    int r = CGI_PutStr(s, bl.c_str(), len);
+    if (r < 0)
+      return r;
   }
 
   return 0;
index d6e59845fabfdae3c56bc41299e5c7d78dc422e0..5c6c49d548f5833cf65ec1e805cf525dcad1fa44 100644 (file)
@@ -479,7 +479,9 @@ int RGWGetObj_REST_SWIFT::send_response(bufferlist& bl)
 
 send_data:
   if (get_data && !orig_ret) {
-    CGI_PutStr(s, bl.c_str(), len);
+    int r = CGI_PutStr(s, bl.c_str(), len);
+    if (r < 0)
+      return r;
   }
   flush_formatter_to_req_state(s, s->formatter);