interface: api cleanup
[vpp.git] / src / vlibapi / api_shared.c
index 5e715d6..65288d8 100644 (file)
@@ -454,7 +454,7 @@ msg_handler_internal (api_main_t * am,
        u32 c;
       } *ed;
       ed = ELOG_DATA (am->elog_main, e);
-      if (id < vec_len (am->msg_names))
+      if (id < vec_len (am->msg_names) && am->msg_names[id])
        ed->c = elog_string (am->elog_main, (char *) am->msg_names[id]);
       else
        ed->c = elog_string (am->elog_main, "BOGUS");
@@ -537,7 +537,7 @@ msg_handler_internal (api_main_t * am,
        u32 c;
       } *ed;
       ed = ELOG_DATA (am->elog_main, e);
-      if (id < vec_len (am->msg_names))
+      if (id < vec_len (am->msg_names) && am->msg_names[id])
        {
          ed->c = elog_string (am->elog_main, (char *) am->msg_names[id]);
          ed->barrier = !am->is_mp_safe[id];
@@ -579,7 +579,7 @@ vl_msg_api_handler_with_vm_node (api_main_t * am, svm_region_t * vlib_rp,
        u32 c;
       } *ed;
       ed = ELOG_DATA (am->elog_main, e);
-      if (id < vec_len (am->msg_names))
+      if (id < vec_len (am->msg_names) && am->msg_names[id])
        ed->c = elog_string (am->elog_main, (char *) am->msg_names[id]);
       else
        ed->c = elog_string (am->elog_main, "BOGUS");
@@ -654,7 +654,21 @@ vl_msg_api_handler_with_vm_node (api_main_t * am, svm_region_t * vlib_rp,
    * main thread without copying them...
    */
   if (id >= vec_len (am->message_bounce) || !(am->message_bounce[id]))
-    vl_msg_api_free (the_msg);
+    {
+      if (is_private)
+       {
+         old_vlib_rp = am->vlib_rp;
+         save_shmem_hdr = am->shmem_hdr;
+         am->vlib_rp = vlib_rp;
+         am->shmem_hdr = (void *) vlib_rp->user_ctx;
+       }
+      vl_msg_api_free (the_msg);
+      if (is_private)
+       {
+         am->vlib_rp = old_vlib_rp;
+         am->shmem_hdr = save_shmem_hdr;
+       }
+    }
 
   if (PREDICT_FALSE (am->elog_trace_api_messages))
     {
@@ -678,7 +692,7 @@ vl_msg_api_handler_with_vm_node (api_main_t * am, svm_region_t * vlib_rp,
        u32 c;
       } *ed;
       ed = ELOG_DATA (am->elog_main, e);
-      if (id < vec_len (am->msg_names))
+      if (id < vec_len (am->msg_names) && am->msg_names[id])
        ed->c = elog_string (am->elog_main, (char *) am->msg_names[id]);
       else
        ed->c = elog_string (am->elog_main, "BOGUS");