X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlibmemory%2Fmemory_api.c;h=1727c28cca107ff36b9d14520ec95a42f2eec15d;hb=33331edd3ab8c2c2109203be7568587664f08abc;hp=a444ec785a76f8478cb1167fa2d7af7152ddc115;hpb=b7b929931a07fbb27b43d5cd105f366c3e29807e;p=vpp.git diff --git a/src/vlibmemory/memory_api.c b/src/vlibmemory/memory_api.c index a444ec785a7..1727c28cca1 100644 --- a/src/vlibmemory/memory_api.c +++ b/src/vlibmemory/memory_api.c @@ -103,6 +103,14 @@ memclnt_queue_callback (vlib_main_t * vm) break; } } + if (vec_len (vm->pending_rpc_requests)) + { + vm->queue_signal_pending = 1; + vm->api_queue_nonempty = 1; + vlib_process_signal_event (vm, vl_api_clnt_node.index, + /* event_type */ QUEUE_SIGNAL_EVENT, + /* event_data */ 0); + } } /* @@ -288,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... */ @@ -314,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 @@ -344,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)); @@ -636,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++) @@ -703,6 +717,32 @@ vl_mem_api_handle_msg_main (vlib_main_t * vm, vlib_node_runtime_t * node) am->shmem_hdr->vl_input_queue); } +int +vl_mem_api_handle_rpc (vlib_main_t * vm, vlib_node_runtime_t * node) +{ + api_main_t *am = &api_main; + int i; + uword *tmp, mp; + + /* + * Swap pending and processing vectors, then process the RPCs + * Avoid deadlock conditions by construction. + */ + clib_spinlock_lock_if_init (&vm->pending_rpc_lock); + tmp = vm->processing_rpc_requests; + vec_reset_length (tmp); + vm->processing_rpc_requests = vm->pending_rpc_requests; + vm->pending_rpc_requests = tmp; + clib_spinlock_unlock_if_init (&vm->pending_rpc_lock); + + for (i = 0; i < vec_len (vm->processing_rpc_requests); i++) + { + mp = vm->processing_rpc_requests[i]; + vl_msg_api_handler_with_vm_node (am, (void *) mp, vm, node); + } + return 0; +} + int vl_mem_api_handle_msg_private (vlib_main_t * vm, vlib_node_runtime_t * node, u32 reg_index) @@ -898,6 +938,28 @@ vlibmemory_init (vlib_main_t * vm) api_main_t *am = &api_main; svm_map_region_args_t _a, *a = &_a; clib_error_t *error; + u8 *remove_path1, *remove_path2; + + /* + * By popular request / to avoid support fires, remove any old api segment + * files Right Here. + */ + if (am->root_path == 0) + { + remove_path1 = format (0, "/dev/shm/global_vm%c", 0); + remove_path2 = format (0, "/dev/shm/vpe-api%c", 0); + } + else + { + remove_path1 = format (0, "/dev/shm/%s-global_vm%c", am->root_path, 0); + remove_path2 = format (0, "/dev/shm/%s-vpe-api%c", am->root_path, 0); + } + + (void) unlink ((char *) remove_path1); + (void) unlink ((char *) remove_path2); + + vec_free (remove_path1); + vec_free (remove_path2); clib_memset (a, 0, sizeof (*a)); a->root_path = am->root_path;