]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add default parameter for clients to time out incase they hit wrong url
authorAdarsh Ashokan <dev.9401adarsh@gmail.com>
Thu, 20 Feb 2025 16:56:17 +0000 (16:56 +0000)
committerAdarsh Ashokan <dev.9401adarsh@gmail.com>
Thu, 20 Feb 2025 17:24:30 +0000 (17:24 +0000)
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 <dev.9401adarsh@gmail.com>
src/rgw/rgw_http_client.cc
src/rgw/rgw_http_client.h

index d3f4b7a4fadf9843987317bc7264fab293de4fd0..670e24ca79c81aa984fd8549670acad0c360ae8b 100644 (file)
@@ -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;
 }
index 51833585c83e035fdf47c983308e0d6ded7b91ba..01762cf7ea5ad256eed1e08269fe0ab2b9b34f43 100644 (file)
@@ -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);