Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
ikev2: fix crash during peer live check
[vpp.git]
/
src
/
vlibmemory
/
memory_client.c
diff --git
a/src/vlibmemory/memory_client.c
b/src/vlibmemory/memory_client.c
index
f78288e
..
c6bfb6f
100644
(file)
--- a/
src/vlibmemory/memory_client.c
+++ b/
src/vlibmemory/memory_client.c
@@
-48,12
+48,24
@@
memory_client_main_t memory_client_main;
__thread memory_client_main_t *my_memory_client_main = &memory_client_main;
memory_client_main_t memory_client_main;
__thread memory_client_main_t *my_memory_client_main = &memory_client_main;
+typedef struct rx_thread_fn_arg
+{
+ api_main_t *am;
+ memory_client_main_t *mm;
+} rx_thread_fn_arg_t;
+
static void *
rx_thread_fn (void *arg)
{
static void *
rx_thread_fn (void *arg)
{
+ rx_thread_fn_arg_t *a = (rx_thread_fn_arg_t *) arg;
+ memory_client_main_t *mm;
svm_queue_t *q;
svm_queue_t *q;
- memory_client_main_t *mm = vlibapi_get_memory_client_main ();
+ vlibapi_set_main (a->am);
+ vlibapi_set_memory_client_main (a->mm);
+ clib_mem_free (a);
+
+ mm = vlibapi_get_memory_client_main ();
q = vlibapi_get_main ()->vl_input_queue;
/* So we can make the rx thread terminate cleanly */
q = vlibapi_get_main ()->vl_input_queue;
/* So we can make the rx thread terminate cleanly */
@@
-148,7
+160,6
@@
void vl_msg_api_send_shmem (svm_queue_t * q, u8 * elem);
int
vl_client_connect (const char *name, int ctx_quota, int input_queue_size)
{
int
vl_client_connect (const char *name, int ctx_quota, int input_queue_size)
{
- svm_region_t *svm;
vl_api_memclnt_create_t *mp;
vl_api_memclnt_create_reply_t *rp;
svm_queue_t *vl_input_queue;
vl_api_memclnt_create_t *mp;
vl_api_memclnt_create_reply_t *rp;
svm_queue_t *vl_input_queue;
@@
-169,7
+180,6
@@
vl_client_connect (const char *name, int ctx_quota, int input_queue_size)
return -1;
}
return -1;
}
- svm = am->vlib_rp;
shmem_hdr = am->shmem_hdr;
if (shmem_hdr == 0 || shmem_hdr->vl_input_queue == 0)
shmem_hdr = am->shmem_hdr;
if (shmem_hdr == 0 || shmem_hdr->vl_input_queue == 0)
@@
-181,12
+191,10
@@
vl_client_connect (const char *name, int ctx_quota, int input_queue_size)
CLIB_MEM_UNPOISON (shmem_hdr, sizeof (*shmem_hdr));
VL_MSG_API_SVM_QUEUE_UNPOISON (shmem_hdr->vl_input_queue);
CLIB_MEM_UNPOISON (shmem_hdr, sizeof (*shmem_hdr));
VL_MSG_API_SVM_QUEUE_UNPOISON (shmem_hdr->vl_input_queue);
- pthread_mutex_lock (&svm->mutex);
- oldheap = svm_push_data_heap (svm);
+ oldheap = vl_msg_push_heap ();
vl_input_queue = svm_queue_alloc_and_init (input_queue_size, sizeof (uword),
getpid ());
vl_input_queue = svm_queue_alloc_and_init (input_queue_size, sizeof (uword),
getpid ());
- svm_pop_heap (oldheap);
- pthread_mutex_unlock (&svm->mutex);
+ vl_msg_pop_heap (oldheap);
am->my_client_index = ~0;
am->my_registration = 0;
am->my_client_index = ~0;
am->my_registration = 0;
@@
-244,11
+252,9
@@
vl_api_memclnt_delete_reply_t_handler (vl_api_memclnt_delete_reply_t * mp)
void *oldheap;
api_main_t *am = vlibapi_get_main ();
void *oldheap;
api_main_t *am = vlibapi_get_main ();
- pthread_mutex_lock (&am->vlib_rp->mutex);
- oldheap = svm_push_data_heap (am->vlib_rp);
+ oldheap = vl_msg_push_heap ();
svm_queue_free (am->vl_input_queue);
svm_queue_free (am->vl_input_queue);
- pthread_mutex_unlock (&am->vlib_rp->mutex);
- svm_pop_heap (oldheap);
+ vl_msg_pop_heap (oldheap);
am->my_client_index = ~0;
am->my_registration = 0;
am->my_client_index = ~0;
am->my_registration = 0;
@@
-389,7
+395,7
@@
vl_client_api_unmap (void)
u8
vl_mem_client_is_connected (void)
{
u8
vl_mem_client_is_connected (void)
{
- return (m
emory_client_main.
connected_to_vlib != 0);
+ return (m
y_memory_client_main->
connected_to_vlib != 0);
}
static int
}
static int
@@
-419,6
+425,15
@@
connect_to_vlib_internal (const char *svm_name,
if (thread_fn)
{
if (thread_fn)
{
+ if (thread_fn == rx_thread_fn)
+ {
+ rx_thread_fn_arg_t *arg;
+ arg = clib_mem_alloc (sizeof (*arg));
+ arg->am = vlibapi_get_main ();
+ arg->mm = vlibapi_get_memory_client_main ();
+ thread_fn_arg = (void *) arg;
+ }
+
rv = pthread_create (&mm->rx_thread_handle,
NULL /*attr */ , thread_fn, thread_fn_arg);
if (rv)
rv = pthread_create (&mm->rx_thread_handle,
NULL /*attr */ , thread_fn, thread_fn_arg);
if (rv)