diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vlibapi/api_common.h | 6 | ||||
-rw-r--r-- | src/vlibmemory/memory_client.c | 23 | ||||
-rw-r--r-- | src/vlibmemory/memory_client.h | 6 |
3 files changed, 34 insertions, 1 deletions
diff --git a/src/vlibapi/api_common.h b/src/vlibapi/api_common.h index c3ef57338bc..4d401046174 100644 --- a/src/vlibapi/api_common.h +++ b/src/vlibapi/api_common.h @@ -378,6 +378,12 @@ vlibapi_get_main (void) return my_api_main; } +always_inline void +vlibapi_set_main (api_main_t * am) +{ + my_api_main = am; +} + #endif /* included_api_common_h */ /* diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c index f78288ed84b..b5090636a7f 100644 --- 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; +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) { + rx_thread_fn_arg_t *a = (rx_thread_fn_arg_t *) arg; + memory_client_main_t *mm; 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 */ @@ -419,6 +431,15 @@ connect_to_vlib_internal (const char *svm_name, 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) diff --git a/src/vlibmemory/memory_client.h b/src/vlibmemory/memory_client.h index 4d79478b80e..a0168693a4b 100644 --- a/src/vlibmemory/memory_client.h +++ b/src/vlibmemory/memory_client.h @@ -70,6 +70,12 @@ vlibapi_get_memory_client_main (void) return my_memory_client_main; } +always_inline void +vlibapi_set_memory_client_main (memory_client_main_t * mm) +{ + my_memory_client_main = mm; +} + #endif /* SRC_VLIBMEMORY_MEMORY_CLIENT_H_ */ /* |