vcl: wait for segments with segment handle

Instead of waiting for notification from binary api.

Change-Id: I5ecab857d6bcdbed62d6bb06709570c4cf6b19ea
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 69f3329..f362896 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -1591,8 +1591,8 @@
 				   local_session_t * ll, u32 opaque)
 {
   u32 seg_size, evt_q_sz, evt_q_elts, margin = 16 << 10;
+  u32 round_rx_fifo_sz, round_tx_fifo_sz, sm_index;
   segment_manager_properties_t *props, *cprops;
-  u32 round_rx_fifo_sz, round_tx_fifo_sz;
   int rv, has_transport, seg_index;
   svm_fifo_segment_private_t *seg;
   application_t *server, *client;
@@ -1654,8 +1654,13 @@
       segment_manager_segment_reader_unlock (sm);
       goto failed;
     }
+  sm_index = segment_manager_index (sm);
   ls->server_rx_fifo->ct_session_index = ls->session_index;
   ls->server_tx_fifo->ct_session_index = ls->session_index;
+  ls->server_rx_fifo->segment_manager = sm_index;
+  ls->server_tx_fifo->segment_manager = sm_index;
+  ls->server_rx_fifo->segment_index = seg_index;
+  ls->server_tx_fifo->segment_index = seg_index;
   ls->svm_segment_index = seg_index;
   ls->listener_index = ll->session_index;
   ls->client_wrk_index = client_wrk->wrk_index;
diff --git a/src/vnet/session/application_interface.c b/src/vnet/session/application_interface.c
index ace9ed2..d254b9b 100644
--- a/src/vnet/session/application_interface.c
+++ b/src/vnet/session/application_interface.c
@@ -558,6 +558,7 @@
 
   ASSERT (vec_len (fs->ssvm.name) <= 128);
   a->segment = &fs->ssvm;
+  a->segment_handle = segment_manager_segment_handle (sm, fs);
 
   segment_manager_segment_reader_unlock (sm);
   vec_free (app_name);
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index ecd99d8..dfb45a7 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -28,6 +28,7 @@
 #undef _
   ssvm_private_t * segment;
   svm_msg_q_t *app_evt_q;
+  u64 segment_handle;
 } vnet_app_attach_args_t;
 
 typedef struct _vnet_app_detach_args_t
diff --git a/src/vnet/session/session.api b/src/vnet/session/session.api
index 3dc0cc8..084678f 100644
--- a/src/vnet/session/session.api
+++ b/src/vnet/session/session.api
@@ -13,7 +13,7 @@
  * limitations under the License.
  */
 
-option version = "1.4.0";
+option version = "1.5.0";
 
 /** \brief client->vpp, attach application to session layer
     @param client_index - opaque cookie to identify the sender
@@ -45,6 +45,7 @@
     @param segment_name_length - length of segment name 
     @param segment_name - name of segment client needs to attach to
     @param app_index - index of the newly created app
+    @param segment_handle - handle for segment
 */
 define application_attach_reply {
     u32 context;
@@ -56,6 +57,7 @@
     u8 segment_name_length;
     u8 segment_name[128];
     u32 app_index;
+    u64 segment_handle;
 };
 
 /** \brief Application add TLS certificate
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index d37b3c9..6ce9e1f 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -825,6 +825,7 @@
 	rmp->app_event_queue_address = pointer_to_uword (a->app_evt_q);
 	rmp->n_fds = n_fds;
 	rmp->fd_flags = fd_flags;
+	rmp->segment_handle = clib_host_to_net_u64 (a->segment_handle);
       }
   }));
   /* *INDENT-ON* */