summaryrefslogtreecommitdiffstats
path: root/src/vcl/vppcom.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-11-13 22:44:54 -0800
committerDamjan Marion <dmarion@me.com>2018-11-14 10:09:14 +0000
commit6917b94f2146aa51195a6a2a1ccd8416a1d74bf3 (patch)
tree03616b51adca1f94fee28edc9f55fd3ae4d08645 /src/vcl/vppcom.c
parent24010fbaa0d0f50add043d3321aa0469ef49cb9e (diff)
vcl/ldp: fix poll
Change-Id: I8eb5546ff8634d5498d8ce5bbc9407bceb9ae3ef Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vcl/vppcom.c')
-rw-r--r--src/vcl/vppcom.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index fad2ac98538..46b1c106d20 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -3185,6 +3185,8 @@ vppcom_poll (vcl_poll_t * vp, uint32_t n_sids, double wait_for_time)
vcl_worker_t *wrk = vcl_worker_get_current ();
f64 timeout = clib_time_now (&wrk->clib_time) + wait_for_time;
u32 i, keep_trying = 1;
+ svm_msg_q_msg_t msg;
+ session_event_t *e;
int rv, num_ev = 0;
VDBG (3, "VCL<%d>: vp %p, nsids %u, wait_for_time %f",
@@ -3197,23 +3199,33 @@ vppcom_poll (vcl_poll_t * vp, uint32_t n_sids, double wait_for_time)
{
vcl_session_t *session;
- for (i = 0; i < n_sids; i++)
+ /* Dequeue all events and drop all unhandled io events */
+ while (svm_msg_q_sub (wrk->app_event_queue, &msg, SVM_Q_NOWAIT, 0) == 0)
{
- ASSERT (vp[i].revents);
+ e = svm_msg_q_msg_data (wrk->app_event_queue, &msg);
+ vcl_handle_mq_event (wrk, e);
+ svm_msg_q_free_msg (wrk->app_event_queue, &msg);
+ }
+ vec_reset_length (wrk->unhandled_evts_vector);
+ for (i = 0; i < n_sids; i++)
+ {
session = vcl_session_get (wrk, vp[i].sid);
if (!session)
- continue;
+ {
+ vp[i].revents = POLLHUP;
+ num_ev++;
+ continue;
+ }
- if (*vp[i].revents)
- *vp[i].revents = 0;
+ vp[i].revents = 0;
if (POLLIN & vp[i].events)
{
rv = vppcom_session_read_ready (session);
if (rv > 0)
{
- *vp[i].revents |= POLLIN;
+ vp[i].revents |= POLLIN;
num_ev++;
}
else if (rv < 0)
@@ -3221,11 +3233,11 @@ vppcom_poll (vcl_poll_t * vp, uint32_t n_sids, double wait_for_time)
switch (rv)
{
case VPPCOM_ECONNRESET:
- *vp[i].revents = POLLHUP;
+ vp[i].revents = POLLHUP;
break;
default:
- *vp[i].revents = POLLERR;
+ vp[i].revents = POLLERR;
break;
}
num_ev++;
@@ -3237,7 +3249,7 @@ vppcom_poll (vcl_poll_t * vp, uint32_t n_sids, double wait_for_time)
rv = vppcom_session_write_ready (session);
if (rv > 0)
{
- *vp[i].revents |= POLLOUT;
+ vp[i].revents |= POLLOUT;
num_ev++;
}
else if (rv < 0)
@@ -3245,11 +3257,11 @@ vppcom_poll (vcl_poll_t * vp, uint32_t n_sids, double wait_for_time)
switch (rv)
{
case VPPCOM_ECONNRESET:
- *vp[i].revents = POLLHUP;
+ vp[i].revents = POLLHUP;
break;
default:
- *vp[i].revents = POLLERR;
+ vp[i].revents = POLLERR;
break;
}
num_ev++;
@@ -3258,7 +3270,7 @@ vppcom_poll (vcl_poll_t * vp, uint32_t n_sids, double wait_for_time)
if (0) // Note "done:" label used by VCL_SESSION_LOCK_AND_GET()
{
- *vp[i].revents = POLLNVAL;
+ vp[i].revents = POLLNVAL;
num_ev++;
}
}
@@ -3274,7 +3286,7 @@ vppcom_poll (vcl_poll_t * vp, uint32_t n_sids, double wait_for_time)
{
clib_warning ("VCL<%d>: vp[%d].sid %d (0x%x), .events 0x%x, "
".revents 0x%x", getpid (), i, vp[i].sid, vp[i].sid,
- vp[i].events, *vp[i].revents);
+ vp[i].events, vp[i].revents);
}
}
return num_ev;