Skip to content

Commit b5a83f7

Browse files
author
Bence Szigeti
committed
GCVCALLP-127: Fail fast instead of blocking call when async slots are full
1 parent cc31329 commit b5a83f7

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

modules/rest_client/rest_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ int ssl_verifyhost = 1;
6969
int curl_http_version = CURL_HTTP_VERSION_NONE;
7070

7171
int enable_expect_100;
72+
int no_async_fallback;
7273

7374
struct tls_mgm_binds tls_api;
7475

@@ -206,6 +207,7 @@ static const param_export_t params[] = {
206207
{ "enable_expect_100", INT_PARAM, &enable_expect_100 },
207208
{ "no_concurrent_connects", INT_PARAM, &no_concurrent_connects },
208209
{ "curl_conn_lifetime", INT_PARAM, &curl_conn_lifetime },
210+
{ "no_async_fallback", INT_PARAM, &no_async_fallback },
209211
{ 0, 0, 0 }
210212
};
211213

modules/rest_client/rest_methods.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,13 @@ int start_async_http_req(struct sip_msg *msg, enum rest_client_method method,
879879

880880
multi_list = get_multi();
881881
if (!multi_list) {
882+
if (no_async_fallback) {
883+
LM_ERR("failed to get a multi handle, max_async_transfers (%d) "
884+
"reached\n", max_async_transfers);
885+
curl_easy_cleanup(handle);
886+
ret = RCL_NO_MULTI_HANDLE;
887+
goto cleanup;
888+
}
882889
LM_WARN("failed to get a multi handle, doing a blocking transfer\n");
883890
rc = rest_easy_perform(handle, url, NULL);
884891
clean_header_list;

modules/rest_client/rest_methods.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern int ssl_verifyhost;
4848
extern int curl_http_version;
4949
extern int no_concurrent_connects;
5050
extern unsigned int curl_conn_lifetime;
51+
extern int no_async_fallback;
5152

5253
/* handle for use with synchronous reqs */
5354
extern CURL *sync_handle;
@@ -69,6 +70,7 @@ enum rest_client_method {
6970
#define RCL_CONNECT_TIMEOUT -2
7071
#define RCL_TRANSFER_TIMEOUT -3
7172
#define RCL_ALREADY_CONNECTING -4
73+
#define RCL_NO_MULTI_HANDLE -5
7274
#define RCL_INTERNAL_ERR -10
7375

7476
typedef struct _rest_trace_param {

0 commit comments

Comments
 (0)