if (ldp->debug > _lvl) \
{ \
int errno_saved = errno; \
- clib_warning ("ldp<%d>: " _fmt, getpid(), ##_args); \
+ fprintf (stderr, "ldp<%d>: " _fmt "\n", getpid(), ##_args); \
errno = errno_saved; \
}
}
/* *INDENT-OFF* */
- pool_foreach (ldpw, ldp->workers, ({
+ pool_foreach (ldpw, ldp->workers) {
clib_memset (&ldpw->clib_time, 0, sizeof (ldpw->clib_time));
- }));
+ }
/* *INDENT-ON* */
LDBG (0, "LDP initialization: done!");
memset (original, 0, n_bytes);
/* *INDENT-OFF* */
- clib_bitmap_foreach (fd, *resultb, ({
+ clib_bitmap_foreach (fd, *resultb) {
if (fd > nfds)
break;
vlsh = ldp_fd_to_vlsh (fd);
clib_bitmap_set_no_check (*libcb, fd, 1);
else
*vclb = clib_bitmap_set (*vclb, vlsh_to_session_index (vlsh), 1);
- }));
+ }
/* *INDENT-ON* */
si_bits_set = clib_bitmap_last_set (*vclb) + 1;
return 0;
/* *INDENT-OFF* */
- clib_bitmap_foreach (si, vclb, ({
+ clib_bitmap_foreach (si, vclb) {
vlsh = vls_session_index_to_vlsh (si);
ASSERT (vlsh != VLS_INVALID_HANDLE);
fd = ldp_vlsh_to_fd (vlsh);
return -1;
}
FD_SET (fd, libcb);
- }));
+ }
/* *INDENT-ON* */
return 0;
return;
/* *INDENT-OFF* */
- clib_bitmap_foreach (fd, result, ({
+ clib_bitmap_foreach (fd, result)
FD_SET ((int)fd, libcb);
- }));
/* *INDENT-ON* */
}
size = vls_attr (vlsh, VPPCOM_ATTR_GET_NWRITE, 0, 0);
if (size < 0)
{
- LDBG (0, "ERROR: fd %d: vls_attr: vlsh %u returned %d (%s)!",
+ LDBG (0, "ERROR: fd %d: vls_attr: vlsh %u returned %ld (%s)!",
out_fd, vlsh, size, vppcom_retval_str (size));
vec_reset_length (ldpw->io_buffer);
errno = -size;
ep.ip = src_addr;
LDBG (0, "listen fd %d: calling vppcom_session_accept: listen sid %u,"
- " ep %p, flags 0x%x", listen_fd, listen_vlsh, ep, flags);
+ " ep %p, flags 0x%x", listen_fd, listen_vlsh, &ep, flags);
accept_vlsh = vls_accept (listen_vlsh, &ep, flags);
if (accept_vlsh < 0)
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)
if (vlsh != VLS_INVALID_HANDLE)
{
LDBG (1, "epfd %d: calling vls_epoll_ctl: ep_vlsh %d op %d, vlsh %u,"
- " event %p", epfd, vep_vlsh, vlsh, event);
+ " event %p", epfd, vep_vlsh, op, vlsh, event);
rv = vls_epoll_ctl (vep_vlsh, op, vlsh, event);
if (rv != VPPCOM_OK)
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;
return -1;
}
+ /* Make sure the vcl worker is valid. Could be that epoll fd was created on
+ * one thread but it is now used on another */
+ 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);
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;
vcl_poll_t *vp;
double max_time;
- LDBG (3, "fds %p, nfds %d, timeout %d", fds, nfds, timeout);
+ LDBG (3, "fds %p, nfds %ld, timeout %d", fds, nfds, timeout);
if (PREDICT_FALSE (ldpw->clib_time.init_cpu_time == 0))
clib_time_init (&ldpw->clib_time);