api: compute msg table for private registrations

Change-Id: Ibaa236c09c2eeea72ee8a8cc603d407217b4af23
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/vlibmemory/memory_api.c b/src/vlibmemory/memory_api.c
index 1da77c5..1f5da4c 100644
--- a/src/vlibmemory/memory_api.c
+++ b/src/vlibmemory/memory_api.c
@@ -157,6 +157,7 @@
   int rv = 0;
   void *oldheap;
   api_main_t *am = &api_main;
+  u8 *msg_table;
 
   /*
    * This is tortured. Maintain a vlib-address-space private
@@ -209,6 +210,11 @@
     am->serialized_message_table_in_shmem =
       vl_api_serialize_message_table (am, 0);
 
+  if (am->vlib_rp != am->vlib_primary_rp)
+    msg_table = vl_api_serialize_message_table (am, 0);
+  else
+    msg_table = am->serialized_message_table_in_shmem;
+
   pthread_mutex_unlock (&svm->mutex);
   svm_pop_heap (oldheap);
 
@@ -220,8 +226,7 @@
      am->shmem_hdr->application_restarts);
   rp->context = mp->context;
   rp->response = ntohl (rv);
-  rp->message_table =
-    pointer_to_uword (am->serialized_message_table_in_shmem);
+  rp->message_table = pointer_to_uword (msg_table);
 
   vl_msg_api_send_shmem (q, (u8 *) & rp);
 }