+http_server_sessions_reader_lock (void)
+{
+ clib_rwlock_reader_lock (&http_server_main.sessions_lock);
+}
+
+static void
+http_server_sessions_reader_unlock (void)
+{
+ clib_rwlock_reader_unlock (&http_server_main.sessions_lock);
+}
+
+static void
+http_server_sessions_writer_lock (void)
+{
+ clib_rwlock_writer_lock (&http_server_main.sessions_lock);
+}
+
+static void
+http_server_sessions_writer_unlock (void)
+{
+ clib_rwlock_writer_unlock (&http_server_main.sessions_lock);
+}
+
+static http_session_t *
+http_server_session_alloc (u32 thread_index)
+{
+ http_server_main_t *hsm = &http_server_main;
+ http_session_t *hs;
+ pool_get (hsm->sessions[thread_index], hs);
+ memset (hs, 0, sizeof (*hs));
+ hs->session_index = hs - hsm->sessions[thread_index];
+ hs->thread_index = thread_index;
+ hs->timer_handle = ~0;
+ return hs;
+}
+
+static http_session_t *
+http_server_session_get (u32 thread_index, u32 hs_index)
+{
+ http_server_main_t *hsm = &http_server_main;
+ if (pool_is_free_index (hsm->sessions[thread_index], hs_index))
+ return 0;
+ return pool_elt_at_index (hsm->sessions[thread_index], hs_index);
+}
+
+static void
+http_server_session_free (http_session_t * hs)
+{
+ http_server_main_t *hsm = &http_server_main;
+ pool_put (hsm->sessions[hs->thread_index], hs);
+ if (CLIB_DEBUG)
+ memset (hs, 0xfa, sizeof (*hs));
+}
+
+static void
+http_server_session_lookup_add (u32 thread_index, u32 s_index, u32 hs_index)
+{
+ http_server_main_t *hsm = &http_server_main;
+ vec_validate (hsm->session_to_http_session[thread_index], s_index);
+ hsm->session_to_http_session[thread_index][s_index] = hs_index;
+}
+
+static void
+http_server_session_lookup_del (u32 thread_index, u32 s_index)
+{
+ http_server_main_t *hsm = &http_server_main;
+ hsm->session_to_http_session[thread_index][s_index] = ~0;
+}
+
+static http_session_t *
+http_server_session_lookup (u32 thread_index, u32 s_index)
+{
+ http_server_main_t *hsm = &http_server_main;
+ u32 hs_index;
+
+ if (s_index < vec_len (hsm->session_to_http_session[thread_index]))
+ {
+ hs_index = hsm->session_to_http_session[thread_index][s_index];
+ return http_server_session_get (thread_index, hs_index);
+ }
+ return 0;
+}
+
+
+static void
+http_server_session_timer_start (http_session_t * hs)
+{
+ u32 hs_handle;
+ hs_handle = hs->thread_index << 24 | hs->session_index;
+ clib_spinlock_lock (&http_server_main.tw_lock);
+ hs->timer_handle = tw_timer_start_2t_1w_2048sl (&http_server_main.tw,
+ hs_handle, 0, 60);
+ clib_spinlock_unlock (&http_server_main.tw_lock);
+}
+
+static void
+http_server_session_timer_stop (http_session_t * hs)
+{
+ if (hs->timer_handle == ~0)
+ return;
+ clib_spinlock_lock (&http_server_main.tw_lock);
+ tw_timer_stop_2t_1w_2048sl (&http_server_main.tw, hs->timer_handle);
+ 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)
+{
+ vnet_disconnect_args_t _a = { 0 }, *a = &_a;
+ a->handle = hs->vpp_session_handle;
+ a->app_index = http_server_main.app_index;
+ vnet_disconnect_session (a);
+}
+
+static void
+http_process_free (http_server_args * args)