pool_get (vcm->workers, wrk);
memset (wrk, 0, sizeof (*wrk));
wrk->wrk_index = wrk - vcm->workers;
+ wrk->forked_child = ~0;
return wrk;
}
}
void
-vcl_worker_cleanup (void)
+vcl_worker_cleanup (vcl_worker_t * wrk, u8 notify_vpp)
{
- vcl_worker_t *wrk = vcl_worker_get_current ();
-
clib_spinlock_lock (&vcm->workers_lock);
- vcl_send_app_worker_add_del (0 /* is_add */ );
- close (wrk->mqs_epfd);
+ if (notify_vpp)
+ {
+ if (wrk->wrk_index == vcl_get_worker_index ())
+ vcl_send_app_worker_add_del (0 /* is_add */ );
+ else
+ vcl_send_child_worker_del (wrk);
+ }
+ if (wrk->mqs_epfd > 0)
+ close (wrk->mqs_epfd);
hash_free (wrk->session_index_by_vpp_handles);
hash_free (wrk->ct_registration_by_mq);
clib_spinlock_free (&wrk->ct_registration_lock);
vec_free (wrk->mq_events);
vec_free (wrk->mq_msg_vector);
- vcl_set_worker_index (~0);
vcl_worker_free (wrk);
clib_spinlock_unlock (&vcm->workers_lock);
- VDBG (0, "cleaned up worker %u", wrk->wrk_index);
}
static void
vcl_worker_cleanup_cb (void *arg)
{
- vcl_worker_cleanup ();
+ vcl_worker_t *wrk = vcl_worker_get_current ();
+ u32 wrk_index = wrk->wrk_index;
+ vcl_worker_cleanup (wrk, 1 /* notify vpp */ );
+ vcl_set_worker_index (~0);
+ VDBG (0, "cleaned up worker %u", wrk_index);
}
vcl_worker_t *
clib_warning ("failed to add worker to vpp");
return -1;
}
-
if (pthread_key_create (&vcl_worker_stop_key, vcl_worker_cleanup_cb))
clib_warning ("failed to add pthread cleanup function");
if (pthread_setspecific (vcl_worker_stop_key, &wrk->thread_id))
}
void
-vcl_worker_share_sessions (u32 parent_wrk_index)
+vcl_worker_share_sessions (vcl_worker_t * parent_wrk)
{
- vcl_worker_t *parent_wrk, *wrk;
vcl_session_t *new_s;
+ vcl_worker_t *wrk;
- parent_wrk = vcl_worker_get (parent_wrk_index);
if (!parent_wrk->sessions)
return;
return 0;
}
+void
+vcl_segment_table_add (u64 segment_handle, u32 svm_segment_index)
+{
+ clib_rwlock_writer_lock (&vcm->segment_table_lock);
+ hash_set (vcm->segment_table, segment_handle, svm_segment_index);
+ clib_rwlock_writer_unlock (&vcm->segment_table_lock);
+}
+
+u32
+vcl_segment_table_lookup (u64 segment_handle)
+{
+ uword *seg_indexp;
+
+ clib_rwlock_reader_lock (&vcm->segment_table_lock);
+ seg_indexp = hash_get (vcm->segment_table, segment_handle);
+ clib_rwlock_reader_unlock (&vcm->segment_table_lock);
+
+ if (!seg_indexp)
+ return VCL_INVALID_SEGMENT_INDEX;
+ return ((u32) * seg_indexp);
+}
+
+void
+vcl_segment_table_del (u64 segment_handle)
+{
+ clib_rwlock_writer_lock (&vcm->segment_table_lock);
+ hash_unset (vcm->segment_table, segment_handle);
+ clib_rwlock_writer_unlock (&vcm->segment_table_lock);
+}
+
/*
* fd.io coding-style-patch-verification: ON
*