unix_shared_memory_queue_t *q;
memory_client_main_t *mm = &memory_client_main;
api_main_t *am = &api_main;
+ int i;
q = am->vl_input_queue;
if (setjmp (mm->rx_thread_jmpbuf) == 0)
{
mm->rx_thread_jmpbuf_valid = 1;
- while (1)
+ /*
+ * Find an unused slot in the per-cpu-mheaps array,
+ * and grab it for this thread. We need to be able to
+ * push/pop the thread heap without affecting other thread(s).
+ */
+ if (__os_thread_index == 0)
{
- vl_msg_api_queue_handler (q);
+ for (i = 0; i < ARRAY_LEN (clib_per_cpu_mheaps); i++)
+ {
+ if (clib_per_cpu_mheaps[i] == 0)
+ {
+ /* Copy the main thread mheap pointer */
+ clib_per_cpu_mheaps[i] = clib_per_cpu_mheaps[0];
+ __os_thread_index = i;
+ break;
+ }
+ }
+ ASSERT (__os_thread_index > 0);
}
+ while (1)
+ vl_msg_api_queue_handler (q);
}
pthread_exit (0);
}
/* Recreate the vnet-side API message handler table */
tblv = uword_to_pointer (mp->message_table, u8 *);
- serialize_open_vector (sm, tblv);
+ unserialize_open_data (sm, tblv, vec_len (tblv));
unserialize_integer (sm, &nmsgs, sizeof (u32));
for (i = 0; i < nmsgs; i++)
/* drain the queue */
if (ntohs (rp->_vl_msg_id) != VL_API_MEMCLNT_DELETE_REPLY)
{
+ clib_warning ("queue drain: %d", ntohs (rp->_vl_msg_id));
vl_msg_api_handler ((void *) rp);
continue;
}
}
}
+/**
+ * Stave off the binary API dead client reaper
+ * Only sent to inactive clients
+ */
+static void
+vl_api_memclnt_keepalive_t_handler (vl_api_memclnt_keepalive_t * mp)
+{
+ vl_api_memclnt_keepalive_reply_t *rmp;
+ api_main_t *am;
+ vl_shmem_hdr_t *shmem_hdr;
+
+ am = &api_main;
+ shmem_hdr = am->shmem_hdr;
+
+ rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs (VL_API_MEMCLNT_KEEPALIVE_REPLY);
+ rmp->context = mp->context;
+ vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & rmp);
+}
+
#define foreach_api_msg \
_(RX_THREAD_EXIT, rx_thread_exit) \
_(MEMCLNT_CREATE_REPLY, memclnt_create_reply) \
-_(MEMCLNT_DELETE_REPLY, memclnt_delete_reply)
+_(MEMCLNT_DELETE_REPLY, memclnt_delete_reply) \
+_(MEMCLNT_KEEPALIVE, memclnt_keepalive)
-int
-vl_client_api_map (const char *region_name)
+void
+vl_client_install_client_message_handlers (void)
{
- int rv;
-
- if ((rv = vl_map_shmem (region_name, 0 /* is_vlib */ )) < 0)
- {
- return rv;
- }
#define _(N,n) \
vl_msg_api_set_handlers(VL_API_##N, #n, \
sizeof(vl_api_##n##_t), 1);
foreach_api_msg;
#undef _
+}
+
+
+int
+vl_client_api_map (const char *region_name)
+{
+ int rv;
+
+ if ((rv = vl_map_shmem (region_name, 0 /* is_vlib */ )) < 0)
+ return rv;
+
+ vl_client_install_client_message_handlers ();
return 0;
}
static int
connect_to_vlib_internal (const char *svm_name,
const char *client_name,
- int rx_queue_size, int want_pthread)
+ int rx_queue_size, int want_pthread, int do_map)
{
int rv = 0;
memory_client_main_t *mm = &memory_client_main;
- if ((rv = vl_client_api_map (svm_name)))
+ if (do_map && (rv = vl_client_api_map (svm_name)))
{
clib_warning ("vl_client_api map rv %d", rv);
return rv;
const char *client_name, int rx_queue_size)
{
return connect_to_vlib_internal (svm_name, client_name, rx_queue_size,
- 1 /* want pthread */ );
+ 1 /* want pthread */ ,
+ 1 /* do map */ );
}
int
int rx_queue_size)
{
return connect_to_vlib_internal (svm_name, client_name, rx_queue_size,
- 0 /* want pthread */ );
+ 0 /* want pthread */ ,
+ 1 /* do map */ );
+}
+
+int
+vl_client_connect_to_vlib_no_map (const char *svm_name,
+ const char *client_name, int rx_queue_size)
+{
+ return connect_to_vlib_internal (svm_name, client_name, rx_queue_size,
+ 1 /* want pthread */ ,
+ 0 /* dont map */ );
}
void
return rv;
}
-void
-vlib_node_sync_stats (vlib_main_t * vm, vlib_node_t * n)
-{
- clib_warning ("STUB called...");
-}
-
/*
* fd.io coding-style-patch-verification: ON
*