vcl: validate vep handle when copying sessions on fork
When copying sessions from parent on fork, we should validate vep handle
in order to EPOLL_CTL_DEL in vcl_session_cleanup correctly when child
exit.
Type: fix
Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>
Change-Id: I7696ecd898460c9a296d2800e46c7140e2218ed7
diff --git a/src/vcl/vcl_locked.c b/src/vcl/vcl_locked.c
index 44b7ced..30d5f5f 100644
--- a/src/vcl/vcl_locked.c
+++ b/src/vcl/vcl_locked.c
@@ -800,6 +800,34 @@
/* *INDENT-ON* */
}
+static void
+vls_validate_veps (vcl_worker_t *wrk)
+{
+ vcl_session_t *s;
+ u32 session_index, wrk_index;
+
+ pool_foreach (s, wrk->sessions)
+ {
+ if (s->vep.vep_sh != ~0)
+ {
+ vcl_session_handle_parse (s->vep.vep_sh, &wrk_index, &session_index);
+ s->vep.vep_sh = vcl_session_handle_from_index (session_index);
+ }
+ if (s->vep.next_sh != ~0)
+ {
+ vcl_session_handle_parse (s->vep.next_sh, &wrk_index,
+ &session_index);
+ s->vep.next_sh = vcl_session_handle_from_index (session_index);
+ }
+ if (s->vep.prev_sh != ~0)
+ {
+ vcl_session_handle_parse (s->vep.prev_sh, &wrk_index,
+ &session_index);
+ s->vep.prev_sh = vcl_session_handle_from_index (session_index);
+ }
+ }
+}
+
void
vls_worker_copy_on_fork (vcl_worker_t * parent_wrk)
{
@@ -829,6 +857,9 @@
/* *INDENT-ON* */
vls_wrk->vls_pool = pool_dup (vls_parent_wrk->vls_pool);
+ /* Validate vep's handle */
+ vls_validate_veps (wrk);
+
vls_share_sessions (vls_parent_wrk, vls_wrk);
}