]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: avoid race condition in RGWHTTPClient::wait() 21767/head
authorcfanz <songxinyingftd@gmail.com>
Wed, 2 May 2018 07:07:50 +0000 (15:07 +0800)
committercfanz <songxinyingftd@gmail.com>
Wed, 2 May 2018 07:07:54 +0000 (15:07 +0800)
The cond is signaled in RGWHTTPManager's thread, which is
different with the thread executing wait(), so there is a
race condition.

Signed-off-by: cfanz <songxinyingftd@gmail.com>
src/rgw/rgw_http_client.cc

index 25c63a7794dbe8b0148cd6c56be2c6f89bdb0829..2e9ac8da6f02e1e6340ea4a04f3d67db2649d5dd 100644 (file)
@@ -51,6 +51,9 @@ struct rgw_http_req_data : public RefCountedObject {
 
   int wait() {
     Mutex::Locker l(lock);
+    if (done) {
+      return ret;
+    }
     cond.Wait(lock);
     return ret;
   }
@@ -524,11 +527,7 @@ bool RGWHTTPClient::is_done()
  */
 int RGWHTTPClient::wait()
 {
-  if (!req_data->is_done()) {
-    return req_data->wait();
-  }
-
-  return req_data->ret;
+  return req_data->wait();
 }
 
 RGWHTTPClient::~RGWHTTPClient()