summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-06-10 11:20:06 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-06-10 14:28:03 -0700
commit566315c47ff0cb2964f5993533af2c1d8d3dcc0b (patch)
treed2ff57601249388a0aa49d2613975d2477ab31a2
parentcbf860fc030db5353411581a24e44d97e09329ee (diff)
downloadceph-566315c47ff0cb2964f5993533af2c1d8d3dcc0b.tar.gz
rgw: don't busy wait for outgoing rest requests
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_http_client.cc49
-rw-r--r--src/rgw/rgw_http_client.h2
2 files changed, 26 insertions, 25 deletions
diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc
index a3a8c42bdeb..0a000bca40c 100644
--- a/src/rgw/rgw_http_client.cc
+++ b/src/rgw/rgw_http_client.cc
@@ -179,26 +179,26 @@ int RGWHTTPClient::init_async(const char *method, const char *url, void **handle
}
-int RGWHTTPClient::process_request(void *handle, bool *done)
+int RGWHTTPClient::process_request(void *handle, bool wait_for_data, bool *done)
{
multi_req_data *req_data = (multi_req_data *)handle;
int still_running;
int mstatus;
do {
-#if 0
- struct timeval timeout;
+ if (wait_for_data) {
+ struct timeval timeout;
- fd_set fdread;
- fd_set fdwrite;
- fd_set fdexcep;
- int maxfd = -1;
+ fd_set fdread;
+ fd_set fdwrite;
+ fd_set fdexcep;
+ int maxfd = -1;
- long curl_timeo = -1;
+ long curl_timeo = -1;
- FD_ZERO(&fdread);
- FD_ZERO(&fdwrite);
- FD_ZERO(&fdexcep);
+ FD_ZERO(&fdread);
+ FD_ZERO(&fdwrite);
+ FD_ZERO(&fdexcep);
#if 0
/* set a suitable timeout to play around with */
timeout.tv_sec = 1;
@@ -214,21 +214,22 @@ int RGWHTTPClient::process_request(void *handle, bool *done)
}
#endif
- /* get file descriptors from the transfers */
- int ret = curl_multi_fdset(req_data->multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
- if (ret) {
- dout(0) << "ERROR: curl_multi_fdset returned " << ret << dendl;
- return -EIO;
- }
+ /* get file descriptors from the transfers */
+ int ret = curl_multi_fdset(req_data->multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
+ if (ret) {
+ dout(0) << "ERROR: curl_multi_fdset returned " << ret << dendl;
+ return -EIO;
+ }
#warning FIXME: replace select with poll
- ret = select(maxfd+1, &fdread, &fdwrite, &fdexcep, NULL);
- if (ret < 0) {
- ret = -errno;
- dout(0) << "ERROR: select returned " << ret << dendl;
- return ret;
+ ret = select(maxfd+1, &fdread, &fdwrite, &fdexcep, NULL);
+ if (ret < 0) {
+ ret = -errno;
+ dout(0) << "ERROR: select returned " << ret << dendl;
+ return ret;
+ }
}
-#endif
+
mstatus = curl_multi_perform(req_data->multi_handle, &still_running);
dout(20) << "curl_multi_perform returned: " << mstatus << dendl;
switch (mstatus) {
@@ -258,7 +259,7 @@ int RGWHTTPClient::complete_request(void *handle)
bool done;
int ret;
do {
- ret = process_request(handle, &done);
+ ret = process_request(handle, true, &done);
} while (!done && !ret);
multi_req_data *req_data = (multi_req_data *)handle;
delete req_data;
diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h
index 937dfe76ab6..d55230095fb 100644
--- a/src/rgw/rgw_http_client.h
+++ b/src/rgw/rgw_http_client.h
@@ -32,7 +32,7 @@ public:
int process(const char *url) { return process("GET", url); }
int init_async(const char *method, const char *url, void **handle);
- int process_request(void *handle,bool *done);
+ int process_request(void *handle, bool wait_for_data, bool *done);
int complete_request(void *handle);
};