summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
24010fb)
Change-Id: I8eb5546ff8634d5498d8ce5bbc9407bceb9ae3ef
Signed-off-by: Florin Coras <fcoras@cisco.com>
clib_bitmap_t *libc_wr_bitmap;
clib_bitmap_t *libc_ex_bitmap;
vcl_poll_t *vcl_poll;
clib_bitmap_t *libc_wr_bitmap;
clib_bitmap_t *libc_ex_bitmap;
vcl_poll_t *vcl_poll;
+ struct pollfd *libc_poll;
+ u16 *libc_poll_idxs;
u8 select_vcl;
u8 epoll_wait_vcl;
u8 vcl_needs_real_epoll; /*< vcl needs next epoll_create to
u8 select_vcl;
u8 epoll_wait_vcl;
u8 vcl_needs_real_epoll; /*< vcl needs next epoll_create to
{
func_str = "libc_close";
{
func_str = "libc_close";
- if (LDP_DEBUG > 0)
- clib_warning
- ("LDP<%d>: fd %d (0x%x): calling %s(): epfd %u (0x%x)",
- getpid (), fd, fd, func_str, epfd, epfd);
+ LDBG (0, "LDP<%d>: fd %d (0x%x): calling %s(): epfd %u (0x%x)",
+ getpid (), fd, fd, func_str, epfd, epfd);
rv = libc_close (epfd);
if (rv < 0)
rv = libc_close (epfd);
if (rv < 0)
func_str = "vppcom_session_close";
func_str = "vppcom_session_close";
- if (LDP_DEBUG > 0)
- clib_warning ("LDP<%d>: fd %d (0x%x): calling %s(): sid %u (0x%x)",
- getpid (), fd, fd, func_str, sid, sid);
+ LDBG (0, "LDP<%d>: fd %d (0x%x): calling %s(): sid %u (0x%x)",
+ getpid (), fd, fd, func_str, sid, sid);
rv = vppcom_session_close (sid);
if (rv != VPPCOM_OK)
rv = vppcom_session_close (sid);
if (rv != VPPCOM_OK)
{
func_str = "libc_close";
{
func_str = "libc_close";
- if (LDP_DEBUG > 0)
- clib_warning ("LDP<%d>: fd %d (0x%x): calling %s()",
- getpid (), fd, fd, func_str);
+ LDBG (0, "LDP<%d>: fd %d (0x%x): calling %s()", getpid (), fd, fd,
+ func_str);
if (sid != INVALID_SESSION_ID)
{
if (sid != INVALID_SESSION_ID)
{
- func_str = __func__;
-
- clib_warning ("LDP<%d>: LDP-TBD", getpid ());
- errno = ENOSYS;
- rv = -1;
+ func_str = "vppcom_session_close[TODO]";
+ rv = close (fd);
poll (struct pollfd *fds, nfds_t nfds, int timeout)
{
const char *func_str = __func__;
poll (struct pollfd *fds, nfds_t nfds, int timeout)
{
const char *func_str = __func__;
- int rv, i, n_libc_fds, n_revents;
+ int rv, i, n_revents = 0;
u32 sid;
vcl_poll_t *vp;
double wait_for_time;
u32 sid;
vcl_poll_t *vp;
double wait_for_time;
- if (LDP_DEBUG > 3)
- clib_warning ("LDP<%d>: fds %p, nfds %d, timeout %d",
- getpid (), fds, nfds, timeout);
+ LDBG (3, "LDP<%d>: fds %p, nfds %d, timeout %d", getpid (), fds, nfds,
+ timeout);
if (timeout >= 0)
wait_for_time = (f64) timeout / 1000;
else
wait_for_time = -1;
if (timeout >= 0)
wait_for_time = (f64) timeout / 1000;
else
wait_for_time = -1;
for (i = 0; i < nfds; i++)
{
for (i = 0; i < nfds; i++)
{
- if (fds[i].fd >= 0)
- {
- if (LDP_DEBUG > 3)
- clib_warning ("LDP<%d>: fds[%d].fd %d (0x%0x), .events = 0x%x, "
- ".revents = 0x%x", getpid (), i, fds[i].fd,
- fds[i].fd, fds[i].events, fds[i].revents);
+ if (fds[i].fd < 0)
+ continue;
- sid = ldp_sid_from_fd (fds[i].fd);
- if (sid != INVALID_SESSION_ID)
- {
- fds[i].fd = -fds[i].fd;
- vec_add2 (ldp->vcl_poll, vp, 1);
- vp->fds_ndx = i;
- vp->sid = sid;
- vp->events = fds[i].events;
+ LDBG (3, "LDP<%d>: fds[%d] fd %d (0x%0x) events = 0x%x revents = 0x%x",
+ getpid (), i, fds[i].fd, fds[i].fd, fds[i].events,
+ fds[i].revents);
+
+ sid = ldp_sid_from_fd (fds[i].fd);
+ if (sid != INVALID_SESSION_ID)
+ {
+ fds[i].fd = -fds[i].fd;
+ vec_add2 (ldp->vcl_poll, vp, 1);
+ vp->fds_ndx = i;
+ vp->sid = sid;
+ vp->events = fds[i].events;
- if (fds[i].events & POLLRDNORM)
- vp->events |= POLLIN;
- if (fds[i].events & POLLWRNORM)
- vp->events |= POLLOUT;
+ if (fds[i].events & POLLRDNORM)
+ vp->events |= POLLIN;
+ if (fds[i].events & POLLWRNORM)
+ vp->events |= POLLOUT;
- vp->revents = &fds[i].revents;
- }
- else
- n_libc_fds++;
+ vp->revents = fds[i].revents;
+ }
+ else
+ {
+ vec_add1 (ldp->libc_poll, fds[i]);
+ vec_add1 (ldp->libc_poll_idxs, i);
do
{
if (vec_len (ldp->vcl_poll))
{
func_str = "vppcom_poll";
do
{
if (vec_len (ldp->vcl_poll))
{
func_str = "vppcom_poll";
- if (LDP_DEBUG > 3)
- clib_warning ("LDP<%d>: calling %s(): "
- "vcl_poll %p, n_sids %u (0x%x): "
- "n_libc_fds %u",
- getpid (), func_str, ldp->vcl_poll,
- vec_len (ldp->vcl_poll), vec_len (ldp->vcl_poll),
- n_libc_fds);
+ LDBG (3, "LDP<%d>: calling %s(): vcl_poll %p, n_sids %u (0x%x): "
+ "n_libc_fds %u", getpid (), func_str, ldp->vcl_poll,
+ vec_len (ldp->vcl_poll), vec_len (ldp->vcl_poll),
+ vec_len (ldp->libc_poll));
rv = vppcom_poll (ldp->vcl_poll, vec_len (ldp->vcl_poll), 0);
if (rv < 0)
rv = vppcom_poll (ldp->vcl_poll, vec_len (ldp->vcl_poll), 0);
if (rv < 0)
+ if (vec_len (ldp->libc_poll))
{
func_str = "libc_poll";
{
func_str = "libc_poll";
- if (LDP_DEBUG > 3)
- clib_warning ("LDP<%d>: calling %s(): fds %p, nfds %u: n_sids %u",
- getpid (), fds, nfds, vec_len (ldp->vcl_poll));
+ LDBG (3, "LDP<%d>: calling %s(): fds %p, nfds %u: n_sids %u",
+ getpid (), fds, nfds, vec_len (ldp->vcl_poll));
- rv = libc_poll (fds, nfds, 0);
+ rv = libc_poll (ldp->libc_poll, vec_len (ldp->libc_poll), 0);
if (rv < 0)
goto done;
else
if (rv < 0)
goto done;
else
vec_foreach (vp, ldp->vcl_poll)
{
fds[vp->fds_ndx].fd = -fds[vp->fds_ndx].fd;
vec_foreach (vp, ldp->vcl_poll)
{
fds[vp->fds_ndx].fd = -fds[vp->fds_ndx].fd;
+ fds[vp->fds_ndx].revents = vp->revents;
#ifdef __USE_XOPEN2K
if ((fds[vp->fds_ndx].revents & POLLIN) &&
(fds[vp->fds_ndx].events & POLLRDNORM))
#ifdef __USE_XOPEN2K
if ((fds[vp->fds_ndx].revents & POLLIN) &&
(fds[vp->fds_ndx].events & POLLRDNORM))
}
vec_reset_length (ldp->vcl_poll);
}
vec_reset_length (ldp->vcl_poll);
+ for (i = 0; i < vec_len (ldp->libc_poll); i++)
+ {
+ fds[ldp->libc_poll_idxs[i]].revents = ldp->libc_poll[i].revents;
+ }
+ vec_reset_length (ldp->libc_poll_idxs);
+ vec_reset_length (ldp->libc_poll);
+
if (LDP_DEBUG > 3)
{
if (rv < 0)
if (LDP_DEBUG > 3)
{
if (rv < 0)
{
clib_warning ("LDP<%d>: returning %d (0x%x): n_sids %u, "
"n_libc_fds %d", getpid (), rv, rv,
{
clib_warning ("LDP<%d>: returning %d (0x%x): n_sids %u, "
"n_libc_fds %d", getpid (), rv, rv,
- vec_len (ldp->vcl_poll), n_libc_fds);
+ vec_len (ldp->vcl_poll), vec_len (ldp->libc_poll));
for (i = 0; i < nfds; i++)
{
for (i = 0; i < nfds; i++)
{
vcl_worker_t *wrk = vcl_worker_get_current ();
f64 timeout = clib_time_now (&wrk->clib_time) + wait_for_time;
u32 i, keep_trying = 1;
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",
int rv, num_ev = 0;
VDBG (3, "VCL<%d>: vp %p, nsids %u, wait_for_time %f",
{
vcl_session_t *session;
{
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)
session = vcl_session_get (wrk, vp[i].sid);
if (!session)
+ {
+ vp[i].revents = POLLHUP;
+ num_ev++;
+ continue;
+ }
- if (*vp[i].revents)
- *vp[i].revents = 0;
if (POLLIN & vp[i].events)
{
rv = vppcom_session_read_ready (session);
if (rv > 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)
num_ev++;
}
else if (rv < 0)
switch (rv)
{
case VPPCOM_ECONNRESET:
switch (rv)
{
case VPPCOM_ECONNRESET:
- *vp[i].revents = POLLHUP;
+ vp[i].revents = POLLHUP;
- *vp[i].revents = POLLERR;
+ vp[i].revents = POLLERR;
rv = vppcom_session_write_ready (session);
if (rv > 0)
{
rv = vppcom_session_write_ready (session);
if (rv > 0)
{
- *vp[i].revents |= POLLOUT;
+ vp[i].revents |= POLLOUT;
num_ev++;
}
else if (rv < 0)
num_ev++;
}
else if (rv < 0)
switch (rv)
{
case VPPCOM_ECONNRESET:
switch (rv)
{
case VPPCOM_ECONNRESET:
- *vp[i].revents = POLLHUP;
+ vp[i].revents = POLLHUP;
- *vp[i].revents = POLLERR;
+ vp[i].revents = POLLERR;
if (0) // Note "done:" label used by VCL_SESSION_LOCK_AND_GET()
{
if (0) // Note "done:" label used by VCL_SESSION_LOCK_AND_GET()
{
- *vp[i].revents = POLLNVAL;
+ vp[i].revents = POLLNVAL;
{
clib_warning ("VCL<%d>: vp[%d].sid %d (0x%x), .events 0x%x, "
".revents 0x%x", getpid (), i, vp[i].sid, vp[i].sid,
{
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);
uint32_t fds_ndx;
uint32_t sid;
short events;
uint32_t fds_ndx;
uint32_t sid;
short events;
} vcl_poll_t;
typedef struct vppcom_data_segment_
} vcl_poll_t;
typedef struct vppcom_data_segment_