diff options
author | Florin Coras <fcoras@cisco.com> | 2020-07-27 12:47:56 -0700 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2020-08-20 09:54:39 +0000 |
commit | bf03bfa801fb9692ecc32ffb82dba862b7f33b9a (patch) | |
tree | 49cee61c1f5a62d48d46d1f17369f3db9893681c | |
parent | a4a6ce66f5d2aa15a9ec0b33b9e6c87dc3120566 (diff) |
http_static: fix session cleanup
While cherry-picking: Fix extras/scripts/check_commit_msg so it accepts '_' characters in
feature names.
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ibb380eecca76ed9c00ed14c167dfcf576f943db0
(cherry picked from commit 0f4e3c22ed5951e0a68e6b40fda1ac63ab5e3c3e)
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
-rwxr-xr-x | extras/scripts/check_commit_msg.sh | 2 | ||||
-rw-r--r-- | src/plugins/http_static/static_server.c | 71 |
2 files changed, 31 insertions, 42 deletions
diff --git a/extras/scripts/check_commit_msg.sh b/extras/scripts/check_commit_msg.sh index acad40344e9..e2d2735bc6a 100755 --- a/extras/scripts/check_commit_msg.sh +++ b/extras/scripts/check_commit_msg.sh @@ -2,7 +2,7 @@ KNOWN_FEATURES=$(cat MAINTAINERS | sed -ne 's/^I:[[:space:]]*//p') FEATURES=$(git show -s --format=%s --no-color \ - | sed -ne 's/^\([a-z0-9 -]*\):.*$/\1/p') + | sed -ne 's/^\([a-z0-9_ -]*\):.*$/\1/p') KNOWN_TYPES="feature fix refactor style docs test make" TYPE=$(git show -s --format=%b --no-color | sed -ne 's/^Type:[[:space:]]*//p') ERR="=============================== ERROR ===============================" diff --git a/src/plugins/http_static/static_server.c b/src/plugins/http_static/static_server.c index 73ea8895de3..77e3ebd8e13 100644 --- a/src/plugins/http_static/static_server.c +++ b/src/plugins/http_static/static_server.c @@ -243,26 +243,8 @@ http_static_server_detach_cache_entry (http_session_t * hs) vec_free (hs->path); } -/** \brief clean up a session - */ - -static void -http_static_server_session_cleanup (http_session_t * hs) -{ - if (!hs) - return; - - http_static_server_detach_cache_entry (hs); - - http_static_server_session_lookup_del (hs->thread_index, - hs->vpp_session_index); - vec_free (hs->rx_buf); - http_static_server_session_free (hs); -} - /** \brief Disconnect a session */ - static void http_static_server_session_disconnect (http_session_t * hs) { @@ -531,7 +513,6 @@ static void close_session (http_session_t * hs) { http_static_server_session_disconnect (hs); - http_static_server_session_cleanup (hs); } /** \brief Register a builtin GET or POST handler @@ -799,7 +780,7 @@ find_end: dp = pool_elt_at_index (hsm->cache_pool, kv.value); hs->data = dp->data; /* Update the cache entry, mark it in-use */ - lru_update (hsm, dp, vlib_time_now (hsm->vlib_main)); + lru_update (hsm, dp, vlib_time_now (vlib_get_main ())); hs->cache_pool_index = dp - hsm->cache_pool; dp->inuse++; if (hsm->debug_level > 1) @@ -871,7 +852,7 @@ find_end: if (hsm->debug_level > 1) clib_warning ("index %d refcnt now %d", hs->cache_pool_index, dp->inuse); - lru_add (hsm, dp, vlib_time_now (hsm->vlib_main)); + lru_add (hsm, dp, vlib_time_now (vlib_get_main ())); kv.key = (u64) vec_dup (hs->path); kv.value = dp - hsm->cache_pool; /* Add to the lookup table */ @@ -1078,14 +1059,6 @@ http_static_server_session_disconnect_callback (session_t * s) { http_static_server_main_t *hsm = &http_static_server_main; vnet_disconnect_args_t _a = { 0 }, *a = &_a; - http_session_t *hs; - - http_static_server_sessions_writer_lock (); - - hs = http_static_server_session_lookup (s->thread_index, s->session_index); - http_static_server_session_cleanup (hs); - - http_static_server_sessions_writer_unlock (); a->handle = session_handle (s); a->app_index = hsm->app_index; @@ -1100,14 +1073,6 @@ http_static_server_session_reset_callback (session_t * s) { http_static_server_main_t *hsm = &http_static_server_main; vnet_disconnect_args_t _a = { 0 }, *a = &_a; - http_session_t *hs; - - http_static_server_sessions_writer_lock (); - - hs = http_static_server_session_lookup (s->thread_index, s->session_index); - http_static_server_session_cleanup (hs); - - http_static_server_sessions_writer_unlock (); a->handle = session_handle (s); a->app_index = hsm->app_index; @@ -1129,6 +1094,30 @@ http_static_server_add_segment_callback (u32 client_index, u64 segment_handle) return -1; } +static void +http_static_session_cleanup (session_t * s, session_cleanup_ntf_t ntf) +{ + http_session_t *hs; + + if (ntf == SESSION_CLEANUP_TRANSPORT) + return; + + http_static_server_sessions_writer_lock (); + + hs = http_static_server_session_lookup (s->thread_index, s->session_index); + if (!hs) + goto done; + + http_static_server_detach_cache_entry (hs); + http_static_server_session_lookup_del (hs->thread_index, + hs->vpp_session_index); + vec_free (hs->rx_buf); + http_static_server_session_free (hs); + +done: + http_static_server_sessions_writer_unlock (); +} + /** \brief Session-layer virtual function table */ static session_cb_vft_t http_static_server_session_cb_vft = { @@ -1139,7 +1128,8 @@ static session_cb_vft_t http_static_server_session_cb_vft = { .add_segment_callback = http_static_server_add_segment_callback, .builtin_app_rx_callback = http_static_server_rx_callback, .builtin_app_tx_callback = http_static_server_tx_callback, - .session_reset_callback = http_static_server_session_reset_callback + .session_reset_callback = http_static_server_session_reset_callback, + .session_cleanup_callback = http_static_session_cleanup, }; static int @@ -1209,7 +1199,7 @@ http_static_server_listen () } static void -http_static_server_session_cleanup_cb (void *hs_handlep) +http_static_server_session_close_cb (void *hs_handlep) { http_static_server_main_t *hsm = &http_static_server_main; http_session_t *hs; @@ -1225,7 +1215,6 @@ http_static_server_session_cleanup_cb (void *hs_handlep) return; hs->timer_handle = ~0; http_static_server_session_disconnect (hs); - http_static_server_session_cleanup (hs); } /** \brief Expired session timer-wheel callback @@ -1241,7 +1230,7 @@ http_expired_timers_dispatch (u32 * expired_timers) /* Get session handle. The first bit is the timer id */ hs_handle = expired_timers[i] & 0x7FFFFFFF; session_send_rpc_evt_to_thread (hs_handle >> 24, - http_static_server_session_cleanup_cb, + http_static_server_session_close_cb, uword_to_pointer (hs_handle, void *)); } } |