vcl: remove session locks

Support for multi-worker apps will be added in future patches. This also
disables vce.

Change-Id: I43b0ed2d5daa2b3d8f8a12fb18bd89dcdfa0619d
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/vcl/vcl_event.c b/src/vcl/vcl_event.c
index e08f5f3..f8da015 100644
--- a/src/vcl/vcl_event.c
+++ b/src/vcl/vcl_event.c
@@ -29,6 +29,15 @@
  * Definitions for generic event handling in VCL.
  */
 
+#define VCL_EVENTS_LOCK() \
+  clib_spinlock_lock (&(vcm->event_thread.events_lockp))
+#define VCL_EVENTS_UNLOCK() \
+  clib_spinlock_unlock (&(vcm->event_thread.events_lockp))
+#define VCL_IO_SESSIONS_LOCK() \
+  clib_spinlock_lock (&(vcm->session_io_thread.io_sessions_lockp))
+#define VCL_IO_SESSIONS_UNLOCK() \
+  clib_spinlock_unlock (&(vcm->session_io_thread.io_sessions_lockp))
+
 int
 vce_generate_event (vce_event_thread_t * evt, u32 ev_idx)
 {
@@ -294,7 +303,7 @@
 {
   vppcom_session_io_thread_t *evt = (vppcom_session_io_thread_t *) arg;
   u32 *session_indexes = 0, *session_index;
-  int i, rv;
+  int i;
   u32 bytes = 0;
   vcl_session_t *session;
 
@@ -312,9 +321,10 @@
 	{
 	  for (i = 0; i < vec_len (session_indexes); ++i)
 	    {
-	      VCL_SESSION_LOCK_AND_GET (session_indexes[i], &session);
+	      session = vcl_session_get (session_indexes[i]);
+	      if (!session)
+		return NULL;
 	      bytes = svm_fifo_max_dequeue (session->rx_fifo);
-	      VCL_SESSION_UNLOCK ();
 
 	      if (bytes)
 		{
@@ -334,7 +344,7 @@
 
 		  VCL_EVENTS_UNLOCK ();
 
-		  rv = vce_generate_event (&vcm->event_thread, ev_idx);
+		  vce_generate_event (&vcm->event_thread, ev_idx);
 		}
 	    }
 	}
@@ -343,8 +353,6 @@
       ts.tv_nsec = 1000000;	/* 1 millisecond */
       nanosleep (&ts, NULL);
     }
-done:
-  VCL_SESSION_UNLOCK ();
   return NULL;
 }
 
@@ -394,9 +402,7 @@
   vce_event_connect_request_t *ecr;
   vce_event_t *ev;
   vppcom_endpt_t ep;
-
   vcl_session_t *new_session;
-  int rv;
 
   vppcom_session_listener_t *session_listener =
     (vppcom_session_listener_t *) reg->handler_fn_args;
@@ -405,7 +411,9 @@
   ev = vce_get_event_from_index (&vcm->event_thread, reg->ev_idx);
   ecr = vce_get_event_data (ev, sizeof (*ecr));
   VCL_EVENTS_UNLOCK ();
-  VCL_SESSION_LOCK_AND_GET (ecr->accepted_session_index, &new_session);
+  new_session = vcl_session_get (ecr->accepted_session_index);
+  if (!new_session)
+    return;
 
   ep.is_ip4 = new_session->transport.is_ip4;
   ep.port = new_session->transport.rmt_port;
@@ -419,7 +427,6 @@
   vppcom_send_accept_session_reply (new_session->vpp_handle,
 				    new_session->client_context,
 				    0 /* retval OK */ );
-  VCL_SESSION_UNLOCK ();
 
   (session_listener->user_cb) (ecr->accepted_session_index, &ep,
 			       session_listener->user_cb_data);
@@ -438,7 +445,6 @@
   /*TODO - Unregister check in close for this listener */
   return;
 
-done:
   ASSERT (0);			// If we can't get a lock or accepted session fails, lets blow up.
 }
 
@@ -460,12 +466,6 @@
   ev = vce_get_event_from_index (&vcm->event_thread, reg->ev_idx);
   vce_event_connect_request_t *ecr = vce_get_event_data (ev, sizeof (*ecr));
 
-  /* Add the accepted_session_index to the FIFO */
-  VCL_ACCEPT_FIFO_LOCK ();
-  clib_fifo_add1 (vcm->client_session_index_fifo,
-		  ecr->accepted_session_index);
-  VCL_ACCEPT_FIFO_UNLOCK ();
-
   /* Recycling the event. */
   VCL_EVENTS_LOCK ();
   ev->recycle = 1;