vcl: handle invalid sessions in epoll

Change-Id: I62d37f3c05451e5667863a2c6c551872d5dac1ea
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index be3081e..86bb214 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -2542,7 +2542,8 @@
       ASSERT (e->fifo->client_thread_index == vcl_get_worker_index ());
       vcl_fifo_rx_evt_valid_or_break (e->fifo);
       sid = e->fifo->client_session_index;
-      session = vcl_session_get (wrk, sid);
+      if (!(session = vcl_session_get (wrk, sid)))
+	break;
       session_events = session->vep.ev.events;
       if (!(EPOLLIN & session->vep.ev.events) || session->has_rx_evt)
 	break;
@@ -2553,7 +2554,8 @@
       break;
     case FIFO_EVENT_APP_TX:
       sid = e->fifo->client_session_index;
-      session = vcl_session_get (wrk, sid);
+      if (!(session = vcl_session_get (wrk, sid)))
+	break;
       session_events = session->vep.ev.events;
       if (!(EPOLLOUT & session_events))
 	break;
@@ -2564,6 +2566,8 @@
     case SESSION_IO_EVT_CT_TX:
       vcl_fifo_rx_evt_valid_or_break (e->fifo);
       session = vcl_ct_session_get_from_fifo (wrk, e->fifo, 0);
+      if (PREDICT_FALSE (!session))
+	break;
       sid = session->session_index;
       session_events = session->vep.ev.events;
       if (!(EPOLLIN & session->vep.ev.events) || session->has_rx_evt)
@@ -2575,6 +2579,8 @@
       break;
     case SESSION_IO_EVT_CT_RX:
       session = vcl_ct_session_get_from_fifo (wrk, e->fifo, 1);
+      if (PREDICT_FALSE (!session))
+	break;
       sid = session->session_index;
       session_events = session->vep.ev.events;
       if (!(EPOLLOUT & session_events))
@@ -2602,7 +2608,8 @@
       vcl_session_connected_handler (wrk, connected_msg);
       /* Generate EPOLLOUT because there's no connected event */
       sid = vcl_session_index_from_vpp_handle (wrk, connected_msg->handle);
-      session = vcl_session_get (wrk, sid);
+      if (!(session = vcl_session_get (wrk, sid)))
+	break;
       session_events = session->vep.ev.events;
       if (EPOLLOUT & session_events)
 	{