From: Adarsh Ashokan Date: Thu, 20 Feb 2025 16:56:17 +0000 (+0000) Subject: rgw: add default parameter for clients to time out incase they hit wrong url X-Git-Tag: v20.3.0~446^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=520d326ebdd7db305c25f730661c967f2c003438;p=ceph.git rgw: add default parameter for clients to time out incase they hit wrong url this fix ensures clients gracefully time out in case endpoint url is wrongly configured. Fixes: https://tracker.ceph.com/issues/51855 Signed-off-by: Adarsh Ashokan --- diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index d3f4b7a4fadf..670e24ca79c8 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -635,6 +635,7 @@ int RGWHTTPClient::init_request(rgw_http_req_data *_req_data) } curl_easy_setopt(easy_handle, CURLOPT_PRIVATE, (void *)req_data); curl_easy_setopt(easy_handle, CURLOPT_TIMEOUT, req_timeout); + curl_easy_setopt(easy_handle, CURLOPT_CONNECTTIMEOUT, req_connect_timeout); return 0; } diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h index 51833585c83e..01762cf7ea5a 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -64,6 +64,7 @@ protected: param_vec_t headers; long req_timeout{0L}; + long req_connect_timeout{3L}; void init(); @@ -151,6 +152,12 @@ public: req_timeout = timeout; } + // set request for connect phase timeout in seconds. + // ensures wrong url hits don't stay alive post this limit + void set_req_connect_timeout(long connect_timeout) { + req_connect_timeout = connect_timeout; + } + int process(const DoutPrefixProvider* dpp, optional_yield y); int wait(const DoutPrefixProvider* dpp, optional_yield y);