summaryrefslogtreecommitdiffstats
path: root/src/vcl/ldp.c
diff options
context:
space:
mode:
authorhanlin <hanlin_wang@163.com>2020-07-13 11:09:15 +0800
committerFlorin Coras <florin.coras@gmail.com>2020-08-12 01:57:18 +0000
commita3a489691d7f2813702fae2d915120743b860d62 (patch)
tree23a22a25ebe051be37244c45fc3a0732cc296e0d /src/vcl/ldp.c
parent40c07ce7a78af69f7354222d4663a65cd5572049 (diff)
vcl: support multi-threads with session migration
Currently, mutlti-threads only support one dispatch thread and multiple worker threads, eventually only dispatch thread is a vcl worker and can interact with epoll. This patch will register all threads as vcl worker, and then each thread can interact with epoll now. Moreover, session migration also supported, such as socket created in thread A and used (bind, connect and etc.) in thread B. Type: feature Signed-off-by: hanlin <hanlin_wang@163.com> Change-Id: Iab0b43a33466968c1423d7d20faf1460c8589d91
Diffstat (limited to 'src/vcl/ldp.c')
-rw-r--r--src/vcl/ldp.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c
index cda4425e574..fddf45cd502 100644
--- a/src/vcl/ldp.c
+++ b/src/vcl/ldp.c
@@ -2223,7 +2223,7 @@ epoll_create1 (int flags)
if ((errno = -ldp_init ()))
return -1;
- if (ldp->vcl_needs_real_epoll)
+ if (ldp->vcl_needs_real_epoll || vls_use_real_epoll ())
{
/* Make sure workers have been allocated */
if (!ldp->workers)
@@ -2425,7 +2425,7 @@ static inline int
ldp_epoll_pwait_eventfd (int epfd, struct epoll_event *events,
int maxevents, int timeout, const sigset_t * sigmask)
{
- ldp_worker_ctx_t *ldpw = ldp_worker_get_current ();
+ ldp_worker_ctx_t *ldpw;
int libc_epfd, rv = 0, num_ev;
vls_handle_t ep_vlsh;
@@ -2438,6 +2438,11 @@ ldp_epoll_pwait_eventfd (int epfd, struct epoll_event *events,
return -1;
}
+ if (vls_mt_wrk_supported ())
+ if (PREDICT_FALSE (vppcom_worker_index () == ~0))
+ vls_register_vcl_worker ();
+
+ ldpw = ldp_worker_get_current ();
if (epfd == ldpw->vcl_mq_epfd)
return libc_epoll_pwait (epfd, events, maxevents, timeout, sigmask);
@@ -2497,7 +2502,7 @@ ldp_epoll_pwait_eventfd (int epfd, struct epoll_event *events,
rv = vls_epoll_wait (ep_vlsh, events, maxevents, 0);
if (rv > 0)
goto done;
- else if (rv < 0)
+ else if (PREDICT_FALSE (rv < 0))
{
errno = -rv;
rv = -1;