Fixes for buliding for 32bit targets:
[vpp.git] / src / vlibmemory / memory_api.c
index 544e59d..1727c28 100644 (file)
@@ -296,23 +296,27 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp)
       svm = am->vlib_rp;
       int private_registration = 0;
 
-      /*
-       * Note: the API message handling path will set am->vlib_rp
-       * as appropriate for pairwise / private memory segments
-       */
-      rp = vl_msg_api_alloc (sizeof (*rp));
-      rp->_vl_msg_id = ntohs (VL_API_MEMCLNT_DELETE_REPLY);
-      rp->handle = mp->handle;
-      rp->response = 1;
-
-      vl_msg_api_send_shmem (regp->vl_input_queue, (u8 *) & rp);
-
-      if (client_index != regp->vl_api_registration_pool_index)
+      /* Send reply unless client asked us to do the cleanup */
+      if (!mp->do_cleanup)
        {
-         clib_warning ("mismatch client_index %d pool_index %d",
-                       client_index, regp->vl_api_registration_pool_index);
-         vl_msg_api_free (rp);
-         return;
+         /*
+          * Note: the API message handling path will set am->vlib_rp
+          * as appropriate for pairwise / private memory segments
+          */
+         rp = vl_msg_api_alloc (sizeof (*rp));
+         rp->_vl_msg_id = ntohs (VL_API_MEMCLNT_DELETE_REPLY);
+         rp->handle = mp->handle;
+         rp->response = 1;
+
+         vl_msg_api_send_shmem (regp->vl_input_queue, (u8 *) & rp);
+         if (client_index != regp->vl_api_registration_pool_index)
+           {
+             clib_warning ("mismatch client_index %d pool_index %d",
+                           client_index,
+                           regp->vl_api_registration_pool_index);
+             vl_msg_api_free (rp);
+             return;
+           }
        }
 
       /* For horizontal scaling, add a hash table... */
@@ -322,8 +326,8 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp)
          if (am->vlib_private_rps[i] == svm)
            {
              /* Note: account for the memfd header page */
-             u64 virtual_base = svm->virtual_base - MMAP_PAGESIZE;
-             u64 virtual_size = svm->virtual_size + MMAP_PAGESIZE;
+             uword virtual_base = svm->virtual_base - MMAP_PAGESIZE;
+             uword virtual_size = svm->virtual_size + MMAP_PAGESIZE;
 
              /*
               * Kill the registration pool element before we make
@@ -352,6 +356,8 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp)
                          regp->vl_api_registration_pool_index);
          pthread_mutex_lock (&svm->mutex);
          oldheap = svm_push_data_heap (svm);
+         if (mp->do_cleanup)
+           svm_queue_free (regp->vl_input_queue);
          vec_free (regp->name);
          /* Poison the old registration */
          clib_memset (regp, 0xF1, sizeof (*regp));
@@ -644,8 +650,8 @@ vl_mem_api_dead_client_scan (api_main_t * am, vl_shmem_hdr_t * shm, f64 now)
                  int i;
                  svm_region_t *dead_rp = (*regpp)->vlib_rp;
                  /* Note: account for the memfd header page */
-                 u64 virtual_base = dead_rp->virtual_base - MMAP_PAGESIZE;
-                 u64 virtual_size = dead_rp->virtual_size + MMAP_PAGESIZE;
+                 uword virtual_base = dead_rp->virtual_base - MMAP_PAGESIZE;
+                 uword virtual_size = dead_rp->virtual_size + MMAP_PAGESIZE;
 
                  /* For horizontal scaling, add a hash table... */
                  for (i = 0; i < vec_len (am->vlib_private_rps); i++)