]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use non-blocking reads for clear_signal
authorCasey Bodley <cbodley@redhat.com>
Fri, 9 Sep 2016 20:01:16 +0000 (16:01 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 9 Nov 2016 15:29:21 +0000 (10:29 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 1101fcc750cdd8702b2ca570da2cecb47d0ddeae)

src/rgw/rgw_http_client.cc

index 04ffd18a2feb2b2f80adb217045f6b373842ab48..2fa5c91140bca4c2151e166d4d8f183e5c614af9 100644 (file)
@@ -346,10 +346,13 @@ RGWHTTPClient::~RGWHTTPClient()
 
 static int clear_signal(int fd)
 {
-  uint32_t buf;
-  int ret = ::read(fd, (void *)&buf, sizeof(buf));
+  // since we're in non-blocking mode, we can try to read a lot more than
+  // one signal from signal_thread() to avoid later wakeups
+  std::array<char, 256> buf;
+  int ret = ::read(fd, (void *)buf.data(), buf.size());
   if (ret < 0) {
-    return -errno;
+    ret = -errno;
+    return ret == -EAGAIN ? 0 : ret; // clear EAGAIN
   }
   return 0;
 }
@@ -723,6 +726,16 @@ int RGWHTTPManager::set_threaded()
     return r;
   }
 
+  // enable non-blocking reads
+  r = ::fcntl(thread_pipe[0], F_SETFL, O_NONBLOCK);
+  if (r < 0) {
+    r = -errno;
+    ldout(cct, 0) << "ERROR: fcntl() returned errno=" << r << dendl;
+    TEMP_FAILURE_RETRY(::close(thread_pipe[0]));
+    TEMP_FAILURE_RETRY(::close(thread_pipe[1]));
+    return r;
+  }
+
   is_threaded = true;
   reqs_thread = new ReqsThread(this);
   reqs_thread->create("http_manager");