diff options
author | 2018-09-11 17:21:43 +0800 | |
---|---|---|
committer | 2018-09-11 17:25:01 +0800 | |
commit | dcf754b73574b5716ada5eb6064ab374e7b2b964 (patch) | |
tree | f4eb38d707d38509af0c18e968bdc2628bdec236 /stacks/vpp | |
parent | b26713f201a01f285f7cd611f969b60fc2578eb7 (diff) |
Fix: fix epoll problem
The same fd can be added to different epoll.
Change-Id: Ib9d6a6a2f69879dea2fea8d9ae8348d2746b89d5
Signed-off-by: rainbow_0206 <jiangwenjiang@huawei.com>
Diffstat (limited to 'stacks/vpp')
-rw-r--r-- | stacks/vpp/adapt/dmm_vcl_adpt.c | 1 | ||||
-rw-r--r-- | stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch | 62 |
2 files changed, 63 insertions, 0 deletions
diff --git a/stacks/vpp/adapt/dmm_vcl_adpt.c b/stacks/vpp/adapt/dmm_vcl_adpt.c index 1b2b9a9..d4974e2 100644 --- a/stacks/vpp/adapt/dmm_vcl_adpt.c +++ b/stacks/vpp/adapt/dmm_vcl_adpt.c @@ -35,6 +35,7 @@ vpphs_ep_ctl_ops (int epFD, int proFD, int ctl_ops, tmpEvt.data.ptr = pdata; tmpEvt.events = events->events; + tmpEvt.events |= (EPOLLIN | EPOLLOUT); if (DMM_VCL_ADPT_DEBUG > 0) clib_warning ("DMM VCL ADPT<%d>: epfd=%d,fd=%d,ops=%d, events=%u", diff --git a/stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch b/stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch new file mode 100644 index 0000000..7975e27 --- /dev/null +++ b/stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch @@ -0,0 +1,62 @@ +From bdb9568fe64c6bdfde17f61dac57a7f54214912c Mon Sep 17 00:00:00 2001 +From: Jiang Wenjiang <jiangwenjiang@huawei.com> +Date: Mon, 10 Sep 2018 03:01:41 +0800 +Subject: [PATCH] Fix: fix epoll problem + +The same fd can add to different epoll. +--- + src/vcl/vppcom.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c +index cab2f60..9cb52cb 100644 +--- a/src/vcl/vppcom.c ++++ b/src/vcl/vppcom.c +@@ -162,6 +162,7 @@ typedef struct + u64 options[16]; + elog_track_t elog_track; + vce_event_handler_reg_t *poll_reg; ++ u32 ep_count; //the count that add to epoll + } session_t; + + typedef struct vppcom_cfg_t_ +@@ -3430,6 +3431,7 @@ vppcom_session_write_ready (session_t * session, u32 session_index) + + if (PREDICT_FALSE (session->state & STATE_LISTEN)) + { ++ return 0; + clib_warning ("VCL<%d>: ERROR: vpp handle 0x%llx, sid %u: " + "cannot write to a listen session!", + getpid (), session->vpp_handle, session_index); +@@ -3802,6 +3804,7 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index, + session_t *vep_session; + session_t *session; + int rv; ++ int ep_cnt = 0; + + if (vep_idx == session_index) + { +@@ -3846,6 +3849,9 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index, + switch (op) + { + case EPOLL_CTL_ADD: ++ ep_cnt = __sync_add_and_fetch (&(session->ep_count), 1); ++ if (ep_cnt != 1) ++ break; + if (PREDICT_FALSE (!event)) + { + clib_warning ("VCL<%d>: ERROR: EPOLL_CTL_ADD: NULL pointer to " +@@ -3950,6 +3956,10 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index, + break; + + case EPOLL_CTL_DEL: ++ ep_cnt = __sync_sub_and_fetch (&(session->ep_count), 1); ++ if (ep_cnt != 0) ++ break; ++ + if (PREDICT_FALSE (!session->is_vep_session)) + { + clib_warning ("VCL<%d>: ERROR: sid %u EPOLL_CTL_DEL: " +-- +1.8.3.1 + |