session/tcp: improve preallocated segment handling

- add preallocated segment flag
- don't remove pre-allocated segments except if application detaches
- when preallocating fifos in multiple segments, completely fill
  a segment before moving to the next
- detach server application from segment-managers when deleting app
- batch syn/syn-ack/fin (re)transmissions
- loosen up close-wait and time-wait times

Change-Id: I412f53ce601cc83b3acc26aeffd7fa2d52d73b03
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 792e661..dc930ce 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -453,7 +453,7 @@
 						   st);
   if (handle == HALF_OPEN_LOOKUP_INVALID_VALUE)
     {
-      clib_warning ("half-open was removed!");
+      TCP_DBG ("half-open was removed!");
       return -1;
     }
 
@@ -732,6 +732,7 @@
 				    u32 thread_index)
 {
   static u16 serial_number = 0;
+  u32 tries = 0;
   session_fifo_event_t evt;
   unix_shared_memory_queue_t *q;
 
@@ -741,21 +742,14 @@
   evt.event_id = serial_number++;
 
   q = session_manager_get_vpp_event_queue (thread_index);
-
-  /* Based on request block (or not) for lack of space */
-  if (PREDICT_TRUE (q->cursize < q->maxsize))
+  while (unix_shared_memory_queue_add (q, (u8 *) & evt, 1))
     {
-      if (unix_shared_memory_queue_add (q, (u8 *) & evt,
-					0 /* do wait for mutex */ ))
+      if (tries++ == 3)
 	{
-	  clib_warning ("failed to enqueue evt");
+	  TCP_DBG ("failed to enqueue evt");
+	  break;
 	}
     }
-  else
-    {
-      clib_warning ("queue full");
-      return;
-    }
 }
 
 /**