]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add api to finish streaming writes
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 24 Aug 2017 11:21:54 +0000 (04:21 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:03:11 +0000 (08:03 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rest_client.cc
src/rgw/rgw_rest_client.h

index 20e614adf61a85a95c7c5722baa5079dffc14820..d317f891a6baf7a16ce4704659daf8bd9c02a46a 100644 (file)
@@ -786,6 +786,11 @@ int RGWRESTStreamRWRequest::receive_data(void *ptr, size_t len)
   return len;
 }
 
+void RGWRESTStreamRWRequest::set_stream_write(bool s) {
+  Mutex::Locker wl(write_lock);
+  stream_writes = s;
+}
+
 void RGWRESTStreamRWRequest::add_send_data(bufferlist& bl)
 {
   Mutex::Locker req_locker(get_req_lock());
@@ -794,12 +799,22 @@ void RGWRESTStreamRWRequest::add_send_data(bufferlist& bl)
   _set_write_paused(false);
 }
 
+void RGWRESTStreamRWRequest::finish_write()
+{
+  Mutex::Locker req_locker(get_req_lock());
+  Mutex::Locker wl(write_lock);
+  write_stream_complete = true;
+  _set_write_paused(false);
+}
+
 int RGWRESTStreamRWRequest::send_data(void *ptr, size_t len, bool *pause)
 {
   Mutex::Locker wl(write_lock);
 
   if (outbl.length() == 0) {
-    *pause = true;
+    if (stream_writes && !write_stream_complete) {
+      *pause = true;
+    }
     return 0;
   }
 
index bf64a03f39ad3a6417fe0aad2885337b62f586a3..09f98532432c9b7d38ce13cf84c49b3d274faa20 100644 (file)
@@ -94,6 +94,8 @@ class RGWRESTStreamRWRequest : public RGWRESTSimpleRequest {
   const char *method;
   uint64_t write_ofs{0};
   bool send_paused{false};
+  bool stream_writes{false};
+  bool write_stream_complete{false};
 protected:
   int handle_header(const string& name, const string& val) override;
 public:
@@ -117,6 +119,11 @@ public:
   void set_in_cb(RGWGetDataCB *_cb) { cb = _cb; }
 
   void add_send_data(bufferlist& bl);
+
+  void set_stream_write(bool s);
+
+  /* finish streaming writes */
+  void finish_write();
 };
 
 class RGWRESTStreamReadRequest : public RGWRESTStreamRWRequest {