http_server_session_free (http_session_t * hs)
{
http_server_main_t *hsm = &http_server_main;
- pool_put (hsm->sessions[hs->thread_index], hs);
+ u32 thread = hs->thread_index;
if (CLIB_DEBUG)
memset (hs, 0xfa, sizeof (*hs));
+ pool_put (hsm->sessions[thread], hs);
}
static void
clib_spinlock_unlock (&http_server_main.tw_lock);
}
-static void
-http_server_session_cleanup (http_session_t * hs)
-{
- if (!hs)
- return;
- http_server_session_lookup_del (hs->thread_index, hs->vpp_session_index);
- vec_free (hs->rx_buf);
- http_server_session_timer_stop (hs);
- http_server_session_free (hs);
-}
-
static void
http_server_session_disconnect (http_session_t * hs)
{
"Expires: Mon, 11 Jan 1970 10:10:10 GMT\r\n"
"Connection: close \r\n"
"Pragma: no-cache\r\n"
- "Content-Length: %d\r\n\r\n%s";
+ "Content-Length: %d\r\n\r\n%v";
static const char *http_error_template =
"HTTP/1.1 %s\r\n"
close_session:
http_server_session_disconnect (hs);
- http_server_session_cleanup (hs);
return 0;
postpone:
{
http_server_main_t *hsm = &http_server_main;
vnet_disconnect_args_t _a = { 0 }, *a = &_a;
- http_session_t *hs;
-
- if (!hsm->is_static)
- http_server_sessions_writer_lock ();
-
- hs = http_server_session_lookup (s->thread_index, s->session_index);
- http_server_session_cleanup (hs);
-
- if (!hsm->is_static)
- http_server_sessions_writer_unlock ();
a->handle = session_handle (s);
a->app_index = hsm->app_index;
{
http_server_main_t *hsm = &http_server_main;
vnet_disconnect_args_t _a = { 0 }, *a = &_a;
- http_session_t *hs;
-
- if (!hsm->is_static)
- http_server_sessions_writer_lock ();
-
- hs = http_server_session_lookup (s->thread_index, s->session_index);
- http_server_session_cleanup (hs);
-
- if (!hsm->is_static)
- http_server_sessions_writer_unlock ();
a->handle = session_handle (s);
a->app_index = hsm->app_index;
return -1;
}
+static void
+http_server_cleanup_callback (session_t * s, session_cleanup_ntf_t ntf)
+{
+ http_server_main_t *hsm = &http_server_main;
+ http_session_t *hs;
+
+ if (ntf == SESSION_CLEANUP_TRANSPORT)
+ return;
+
+ if (!hsm->is_static)
+ http_server_sessions_writer_lock ();
+
+ hs = http_server_session_lookup (s->thread_index, s->session_index);
+ if (!hs)
+ goto done;
+
+ http_server_session_lookup_del (hs->thread_index, hs->vpp_session_index);
+ vec_free (hs->rx_buf);
+ http_server_session_timer_stop (hs);
+ http_server_session_free (hs);
+
+done:
+
+ if (!hsm->is_static)
+ http_server_sessions_writer_unlock ();
+}
+
static session_cb_vft_t http_server_session_cb_vft = {
.session_accept_callback = http_server_session_accept_callback,
.session_disconnect_callback = http_server_session_disconnect_callback,
.session_connected_callback = http_server_session_connected_callback,
.add_segment_callback = http_server_add_segment_callback,
.builtin_app_rx_callback = http_server_rx_callback,
- .session_reset_callback = http_server_session_reset_callback
+ .session_reset_callback = http_server_session_reset_callback,
+ .session_cleanup_callback = http_server_cleanup_callback,
};
static int
}
static void
-http_server_session_cleanup_cb (void *hs_handlep)
+http_server_session_close_cb (void *hs_handlep)
{
http_session_t *hs;
uword hs_handle;
return;
hs->timer_handle = ~0;
http_server_session_disconnect (hs);
- http_server_session_cleanup (hs);
}
static void
/* 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_server_session_cleanup_cb,
+ http_server_session_close_cb,
uword_to_pointer (hs_handle, void *));
}
}