From: Casey Bodley Date: Fri, 9 Sep 2016 20:01:16 +0000 (-0400) Subject: rgw: use non-blocking reads for clear_signal X-Git-Tag: v11.0.1~242^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1101fcc750cdd8702b2ca570da2cecb47d0ddeae;p=ceph.git rgw: use non-blocking reads for clear_signal Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index 97e146b78dbb..a83140bf5099 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -420,10 +420,13 @@ int RGWHTTPTransceiver::send_data(void* ptr, size_t len) 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 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; } @@ -797,6 +800,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");