Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
session: cleanup use of api_client_index
[vpp.git]
/
src
/
vcl
/
vcl_private.c
diff --git
a/src/vcl/vcl_private.c
b/src/vcl/vcl_private.c
index
f997c23
..
d159a49
100644
(file)
--- a/
src/vcl/vcl_private.c
+++ b/
src/vcl/vcl_private.c
@@
-15,7
+15,7
@@
#include <vcl/vcl_private.h>
#include <vcl/vcl_private.h>
-pthread_key_t vcl_worker_stop_key;
+
static
pthread_key_t vcl_worker_stop_key;
static const char *
vppcom_app_state_str (app_state_t state)
static const char *
vppcom_app_state_str (app_state_t state)
@@
-246,6
+246,13
@@
vcl_worker_alloc_and_init ()
if (vcl_get_worker_index () != ~0)
return 0;
if (vcl_get_worker_index () != ~0)
return 0;
+ if (pool_elts (vcm->workers) == vcm->cfg.max_workers)
+ {
+ VDBG (0, "max-workers %u limit reached", vcm->cfg.max_workers);
+ return 0;
+ }
+
+ clib_spinlock_lock (&vcm->workers_lock);
wrk = vcl_worker_alloc ();
vcl_set_worker_index (wrk->wrk_index);
wrk = vcl_worker_alloc ();
vcl_set_worker_index (wrk->wrk_index);
@@
-267,12
+274,15
@@
vcl_worker_alloc_and_init ()
vec_validate (wrk->mq_events, 64);
vec_validate (wrk->mq_msg_vector, 128);
vec_reset_length (wrk->mq_msg_vector);
vec_validate (wrk->mq_events, 64);
vec_validate (wrk->mq_msg_vector, 128);
vec_reset_length (wrk->mq_msg_vector);
+ vec_validate (wrk->unhandled_evts_vector, 128);
+ vec_reset_length (wrk->unhandled_evts_vector);
if (wrk->wrk_index == 0)
if (wrk->wrk_index == 0)
- return wrk;
+ {
+ clib_spinlock_unlock (&vcm->workers_lock);
+ return wrk;
+ }
- while (vcm->app_state == STATE_APP_ADDING_WORKER)
- ;
vcm->app_state = STATE_APP_ADDING_WORKER;
vcl_send_app_worker_add_del (1 /* is_add */ );
if (vcl_wait_for_app_state_change (STATE_APP_READY))
vcm->app_state = STATE_APP_ADDING_WORKER;
vcl_send_app_worker_add_del (1 /* is_add */ );
if (vcl_wait_for_app_state_change (STATE_APP_READY))
@@
-283,6
+293,11
@@
vcl_worker_alloc_and_init ()
if (pthread_key_create (&vcl_worker_stop_key, vcl_worker_cleanup))
clib_warning ("failed to add pthread cleanup function");
if (pthread_key_create (&vcl_worker_stop_key, vcl_worker_cleanup))
clib_warning ("failed to add pthread cleanup function");
+ if (pthread_setspecific (vcl_worker_stop_key, &wrk->thread_id))
+ clib_warning ("failed to setup key value");
+ wrk->thread_id = pthread_self ();
+
+ clib_spinlock_unlock (&vcm->workers_lock);
VDBG (0, "added worker %u", wrk->wrk_index);
VDBG (0, "added worker %u", wrk->wrk_index);