session: use llist in session node evt handling

Type: refactor

Change-Id: I24159e0a848f552b4e27acfb5fe6f2cd91b50a19
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index e7542ae..9769c01 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -122,18 +122,19 @@
 session_program_transport_close (session_t * s)
 {
   u32 thread_index = vlib_get_thread_index ();
+  session_evt_elt_t *elt;
   session_worker_t *wrk;
-  session_event_t *evt;
 
   /* If we are in the handler thread, or being called with the worker barrier
    * held, just append a new event to pending disconnects vector. */
   if (vlib_thread_is_main_w_barrier () || thread_index == s->thread_index)
     {
       wrk = session_main_get_worker (s->thread_index);
-      vec_add2 (wrk->pending_disconnects, evt, 1);
-      clib_memset (evt, 0, sizeof (*evt));
-      evt->session_handle = session_handle (s);
-      evt->event_type = SESSION_CTRL_EVT_CLOSE;
+      elt = session_evt_elt_alloc (wrk);
+      clib_memset (&elt->evt, 0, sizeof (session_event_t));
+      elt->evt.session_handle = session_handle (s);
+      elt->evt.event_type = SESSION_CTRL_EVT_CLOSE;
+      session_evt_add_pending_disconnects (wrk, elt);
     }
   else
     session_send_ctrl_evt_to_thread (s, SESSION_CTRL_EVT_CLOSE);
@@ -1380,15 +1381,11 @@
   for (i = 0; i < num_threads; i++)
     {
       wrk = &smm->wrk[i];
-      vec_validate (wrk->free_event_vector, 128);
-      _vec_len (wrk->free_event_vector) = 0;
-      vec_validate (wrk->pending_event_vector, 128);
-      _vec_len (wrk->pending_event_vector) = 0;
-      vec_validate (wrk->pending_disconnects, 128);
-      _vec_len (wrk->pending_disconnects) = 0;
-      vec_validate (wrk->postponed_event_vector, 128);
-      _vec_len (wrk->postponed_event_vector) = 0;
-
+      wrk->new_head = clib_llist_make_head (wrk->event_elts, evt_list);
+      wrk->pending_head = clib_llist_make_head (wrk->event_elts, evt_list);
+      wrk->postponed_head = clib_llist_make_head (wrk->event_elts, evt_list);
+      wrk->disconnects_head = clib_llist_make_head (wrk->event_elts,
+						    evt_list);
       wrk->last_vlib_time = vlib_time_now (vlib_mains[i]);
       wrk->dispatch_period = 500e-6;