aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/http
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2024-10-17 13:41:51 +0200
committerFlorin Coras <florin.coras@gmail.com>2024-10-25 23:33:15 +0000
commit841672258a55defb28b1ca6a35b6ad9830c132cf (patch)
treed9a0fa5366f5c53c8040b03e0904ee2569562b40 /src/plugins/http
parentdced40dcaca0186d11eccbf5c75e21446db931b9 (diff)
http: pass timeout using extended config
App can now pass http connection timeout using extended configuration, ext cfg type TRANSPORT_ENDPT_EXT_CFG_HTTP, value (in seconds) set in ext cfg member opaque. It is optional, default value is 60 seconds. Type: improvement Change-Id: Ibeff4bbd3153421be350ff564ec3c8e52e5b9639 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/http')
-rw-r--r--src/plugins/http/http.c22
-rw-r--r--src/plugins/http/http.h1
-rw-r--r--src/plugins/http/http_timer.h11
3 files changed, 25 insertions, 9 deletions
diff --git a/src/plugins/http/http.c b/src/plugins/http/http.c
index 6afb80d11c4..8c145da7b20 100644
--- a/src/plugins/http/http.c
+++ b/src/plugins/http/http.c
@@ -158,6 +158,7 @@ http_ho_conn_alloc (void)
hc->h_hc_index = hc - hm->ho_conn_pool;
hc->h_pa_session_handle = SESSION_INVALID_HANDLE;
hc->h_tc_session_handle = SESSION_INVALID_HANDLE;
+ hc->timeout = HTTP_CONN_TIMEOUT;
return hc->h_hc_index;
}
@@ -169,6 +170,7 @@ http_listener_alloc (void)
pool_get_zero (hm->listener_pool, lhc);
lhc->c_c_index = lhc - hm->listener_pool;
+ lhc->timeout = HTTP_CONN_TIMEOUT;
return lhc->c_c_index;
}
@@ -1821,6 +1823,7 @@ http_transport_connect (transport_endpoint_cfg_t *tep)
int error;
u32 hc_index;
session_t *ho;
+ transport_endpt_ext_cfg_t *ext_cfg;
app_worker_t *app_wrk = app_worker_get (sep->app_wrk_index);
clib_memset (cargs, 0, sizeof (*cargs));
@@ -1837,6 +1840,13 @@ http_transport_connect (transport_endpoint_cfg_t *tep)
hc->state = HTTP_CONN_STATE_CONNECTING;
cargs->api_context = hc_index;
+ ext_cfg = session_endpoint_get_ext_cfg (sep, TRANSPORT_ENDPT_EXT_CFG_HTTP);
+ if (ext_cfg)
+ {
+ HTTP_DBG (1, "app set timeout %u", ext_cfg->opaque);
+ hc->timeout = ext_cfg->opaque;
+ }
+
hc->is_server = 0;
if (vec_len (app->name))
@@ -1894,7 +1904,10 @@ http_start_listen (u32 app_listener_index, transport_endpoint_cfg_t *tep)
ext_cfg = session_endpoint_get_ext_cfg (sep, TRANSPORT_ENDPT_EXT_CFG_CRYPTO);
if (ext_cfg)
- tp = TRANSPORT_PROTO_TLS;
+ {
+ HTTP_DBG (1, "app set tls");
+ tp = TRANSPORT_PROTO_TLS;
+ }
args->sep_ext.transport_proto = tp;
if (vnet_listen (args))
@@ -1903,6 +1916,13 @@ http_start_listen (u32 app_listener_index, transport_endpoint_cfg_t *tep)
lhc_index = http_listener_alloc ();
lhc = http_listener_get (lhc_index);
+ ext_cfg = session_endpoint_get_ext_cfg (sep, TRANSPORT_ENDPT_EXT_CFG_HTTP);
+ if (ext_cfg)
+ {
+ HTTP_DBG (1, "app set timeout %u", ext_cfg->opaque);
+ lhc->timeout = ext_cfg->opaque;
+ }
+
/* Grab transport connection listener and link to http listener */
lhc->h_tc_session_handle = args->handle;
al = app_listener_get_w_handle (lhc->h_tc_session_handle);
diff --git a/src/plugins/http/http.h b/src/plugins/http/http.h
index abaa8f81447..b984c9564d6 100644
--- a/src/plugins/http/http.h
+++ b/src/plugins/http/http.h
@@ -388,6 +388,7 @@ typedef struct http_tc_
http_conn_state_t state;
u32 timer_handle;
+ u32 timeout;
u8 pending_timer;
u8 *app_name;
u8 *host;
diff --git a/src/plugins/http/http_timer.h b/src/plugins/http/http_timer.h
index 06baa1f8557..43d20d004d8 100644
--- a/src/plugins/http/http_timer.h
+++ b/src/plugins/http/http_timer.h
@@ -43,15 +43,13 @@ http_conn_timer_start (http_conn_t *hc)
{
http_tw_ctx_t *twc = &http_tw_ctx;
u32 hs_handle;
- u64 timeout;
ASSERT (hc->timer_handle == HTTP_TIMER_HANDLE_INVALID);
- timeout = HTTP_CONN_TIMEOUT;
hs_handle = hc->c_thread_index << 24 | hc->c_c_index;
clib_spinlock_lock (&twc->tw_lock);
hc->timer_handle =
- tw_timer_start_2t_1w_2048sl (&twc->tw, hs_handle, 0, timeout);
+ tw_timer_start_2t_1w_2048sl (&twc->tw, hs_handle, 0, hc->timeout);
clib_spinlock_unlock (&twc->tw_lock);
}
@@ -74,19 +72,16 @@ static inline void
http_conn_timer_update (http_conn_t *hc)
{
http_tw_ctx_t *twc = &http_tw_ctx;
- u64 timeout;
u32 hs_handle;
- timeout = HTTP_CONN_TIMEOUT;
-
clib_spinlock_lock (&twc->tw_lock);
if (hc->timer_handle != HTTP_TIMER_HANDLE_INVALID)
- tw_timer_update_2t_1w_2048sl (&twc->tw, hc->timer_handle, timeout);
+ tw_timer_update_2t_1w_2048sl (&twc->tw, hc->timer_handle, hc->timeout);
else
{
hs_handle = hc->c_thread_index << 24 | hc->c_c_index;
hc->timer_handle =
- tw_timer_start_2t_1w_2048sl (&twc->tw, hs_handle, 0, timeout);
+ tw_timer_start_2t_1w_2048sl (&twc->tw, hs_handle, 0, hc->timeout);
}
clib_spinlock_unlock (&twc->tw_lock);
}