summaryrefslogtreecommitdiffstats
path: root/src/vlibmemory/memory_api.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-01-15 01:08:33 -0800
committerDave Barach <openvpp@barachs.net>2018-01-25 23:53:35 +0000
commitb384b543313b6b47a277c903e9d4fcd4343054fa (patch)
tree1996e3a25eb3a32fe5bbc405d75f38dd041a5a40 /src/vlibmemory/memory_api.c
parent4e578068fc3fe8ba176d211123ddd88962dab315 (diff)
session: add support for memfd segments
- update segment manager and session api to work with both flavors of ssvm segments - added generic ssvm slave/master init and del functions - cleanup/refactor tcp_echo - fixed uses of svm fifo pool as vector Change-Id: Ieee8b163faa407da6e77e657a2322de213a9d2a0 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vlibmemory/memory_api.c')
-rw-r--r--src/vlibmemory/memory_api.c104
1 files changed, 58 insertions, 46 deletions
diff --git a/src/vlibmemory/memory_api.c b/src/vlibmemory/memory_api.c
index 752f50717b0..0ee1384f22b 100644
--- a/src/vlibmemory/memory_api.c
+++ b/src/vlibmemory/memory_api.c
@@ -198,6 +198,7 @@ vl_api_memclnt_create_t_handler (vl_api_memclnt_create_t * mp)
regp->vl_api_registration_pool_index = regpp - am->vl_clients;
regp->vlib_rp = svm;
regp->shmem_hdr = am->shmem_hdr;
+ regp->clib_file_index = am->shmem_hdr->clib_file_index;
q = regp->vl_input_queue = (svm_queue_t *) (uword) mp->input_queue;
@@ -273,7 +274,7 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp)
return;
}
- regpp = am->vl_clients + client_index;
+ regpp = pool_elt_at_index (am->vl_clients, client_index);
if (!pool_is_free (am->vl_clients, regpp))
{
@@ -509,11 +510,54 @@ send_memclnt_keepalive (vl_api_registration_t * regp, f64 now)
am->shmem_hdr = save_shmem_hdr;
}
+static void
+vl_mem_send_client_keepalive_w_reg (api_main_t * am, f64 now,
+ vl_api_registration_t ** regpp,
+ u32 ** dead_indices,
+ u32 ** confused_indices)
+{
+ vl_api_registration_t *regp = *regpp;
+ if (regp)
+ {
+ /* If we haven't heard from this client recently... */
+ if (regp->last_heard < (now - 10.0))
+ {
+ if (regp->unanswered_pings == 2)
+ {
+ svm_queue_t *q;
+ q = regp->vl_input_queue;
+ if (kill (q->consumer_pid, 0) >= 0)
+ {
+ clib_warning ("REAPER: lazy binary API client '%s'",
+ regp->name);
+ regp->unanswered_pings = 0;
+ regp->last_heard = now;
+ }
+ else
+ {
+ clib_warning ("REAPER: binary API client '%s' died",
+ regp->name);
+ vec_add1 (*dead_indices, regpp - am->vl_clients);
+ }
+ }
+ else
+ send_memclnt_keepalive (regp, now);
+ }
+ else
+ regp->unanswered_pings = 0;
+ }
+ else
+ {
+ clib_warning ("NULL client registration index %d",
+ regpp - am->vl_clients);
+ vec_add1 (*confused_indices, regpp - am->vl_clients);
+ }
+}
+
void
vl_mem_api_dead_client_scan (api_main_t * am, vl_shmem_hdr_t * shm, f64 now)
{
vl_api_registration_t **regpp;
- vl_api_registration_t *regp;
static u32 *dead_indices;
static u32 *confused_indices;
@@ -521,46 +565,12 @@ vl_mem_api_dead_client_scan (api_main_t * am, vl_shmem_hdr_t * shm, f64 now)
vec_reset_length (confused_indices);
/* *INDENT-OFF* */
- pool_foreach (regpp, am->vl_clients,
- ({
- regp = *regpp;
- if (regp)
- {
- /* If we haven't heard from this client recently... */
- if (regp->last_heard < (now - 10.0))
- {
- if (regp->unanswered_pings == 2)
- {
- svm_queue_t *q;
- q = regp->vl_input_queue;
- if (kill (q->consumer_pid, 0) >=0)
- {
- clib_warning ("REAPER: lazy binary API client '%s'",
- regp->name);
- regp->unanswered_pings = 0;
- regp->last_heard = now;
- }
- else
- {
- clib_warning ("REAPER: binary API client '%s' died",
- regp->name);
- vec_add1(dead_indices, regpp - am->vl_clients);
- }
- }
- else
- send_memclnt_keepalive (regp, now);
- }
- else
- regp->unanswered_pings = 0;
- }
- else
- {
- clib_warning ("NULL client registration index %d",
- regpp - am->vl_clients);
- vec_add1 (confused_indices, regpp - am->vl_clients);
- }
+ pool_foreach (regpp, am->vl_clients, ({
+ vl_mem_send_client_keepalive_w_reg (am, now, regpp, &dead_indices,
+ &confused_indices);
}));
/* *INDENT-ON* */
+
/* This should "never happen," but if it does, fix it... */
if (PREDICT_FALSE (vec_len (confused_indices) > 0))
{
@@ -702,24 +712,26 @@ vl_mem_api_client_index_to_registration (u32 handle)
vl_api_registration_t **regpp;
vl_api_registration_t *regp;
api_main_t *am = &api_main;
+ vl_shmem_hdr_t *shmem_hdr;
u32 index;
index = vl_msg_api_handle_get_index (handle);
- if ((am->shmem_hdr->application_restarts & VL_API_EPOCH_MASK)
- != vl_msg_api_handle_get_epoch (handle))
+ regpp = am->vl_clients + index;
+
+ if (pool_is_free (am->vl_clients, regpp))
{
vl_msg_api_increment_missing_client_counter ();
return 0;
}
+ regp = *regpp;
- regpp = am->vl_clients + index;
-
- if (pool_is_free (am->vl_clients, regpp))
+ shmem_hdr = (vl_shmem_hdr_t *) regp->shmem_hdr;
+ if (!vl_msg_api_handle_is_valid (handle, shmem_hdr->application_restarts))
{
vl_msg_api_increment_missing_client_counter ();
return 0;
}
- regp = *regpp;
+
return (regp);
}