summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2017-11-10 15:49:32 -0500
committerFlorin Coras <florin.coras@gmail.com>2017-11-10 22:13:32 +0000
commit375e468da3105ed33e164feb572e1c70d826307c (patch)
tree997409ea7ef504145b61ec8699d15b6e89c54979 /src
parentb8d4481a93f919291d4b682ef0ac8948a9f1be32 (diff)
VCL-LDPRELOAD: Fix epoll_pwait timeout.
Change-Id: I5712f45c35dbdf34141c42b9d864cad1f918e5e8 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/vcl/vcom.c6
-rw-r--r--src/vcl/vcom_socket.c23
2 files changed, 17 insertions, 12 deletions
diff --git a/src/vcl/vcom.c b/src/vcl/vcom.c
index ed52bfac8e4..624f0247e47 100644
--- a/src/vcl/vcom.c
+++ b/src/vcl/vcom.c
@@ -196,12 +196,10 @@ close (int __fd)
if (is_vcom_socket_fd (__fd) || is_vcom_epfd (__fd))
{
if (VCOM_DEBUG > 0)
- vcom_socket_main_show ();
+ fprintf (stderr, "[%d] close: fd %d\n", pid, __fd);
rv = vcom_close (__fd);
if (VCOM_DEBUG > 0)
- fprintf (stderr, "[%d] close: " "'%04d'='%04d'\n", pid, rv, __fd);
- if (VCOM_DEBUG > 0)
- vcom_socket_main_show ();
+ fprintf (stderr, "[%d] close: vcom_close() returned %d\n", pid, rv);
if (rv != 0)
{
errno = -rv;
diff --git a/src/vcl/vcom_socket.c b/src/vcl/vcom_socket.c
index 6fcc4e5820e..b2d6f58d794 100644
--- a/src/vcl/vcom_socket.c
+++ b/src/vcl/vcom_socket.c
@@ -2860,7 +2860,7 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
int rv = -EBADF;
int rv2;
double time_to_wait = (double) 0;
- double timeout;
+ double timeout, now = 0;
vcom_epoll_t *vepoll;
i32 vep_idx;
static struct epoll_event *libc_ev = 0;
@@ -2875,8 +2875,7 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
goto out;
}
- time_to_wait = ((__timeout > 0) ?
- (double) __timeout / (double) 1000 : (double) __timeout);
+ time_to_wait = ((__timeout >= 0) ? (double) __timeout / (double) 1000 : 0);
vep_idx = vcom_socket_get_vep_idx_and_vepoll (__epfd, &vepoll);
if (vep_idx == INVALID_VEP_IDX)
@@ -2899,7 +2898,8 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
{
if (VCOM_DEBUG > 2)
fprintf (stderr, "[%d] vcom_socket_epoll_pwait: libc_cnt = 0, "
- "calling vppcom_epoll_wait()\n", getpid ());
+ "calling vppcom_epoll_wait() time_to_wait = %f\n",
+ getpid (), time_to_wait);
rv = vppcom_epoll_wait (vep_idx, __events, __maxevents, time_to_wait);
}
else if (vepoll->vcl_cnt == 0)
@@ -2913,14 +2913,20 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
{
if (VCOM_DEBUG > 2)
fprintf (stderr, "[%d] vcom_socket_epoll_pwait: vcl_cnt = %d, "
- "libc_cnt = %d -> mixed polling\n", getpid (),
- vepoll->vcl_cnt, vepoll->libc_cnt);
+ "libc_cnt = %d -> mixed polling (time_to_wait = %f, "
+ "__timeout = %d)\n",
+ getpid (), vepoll->vcl_cnt, vepoll->libc_cnt,
+ time_to_wait, __timeout);
vec_validate (libc_ev, __maxevents);
timeout = clib_time_now (&vsm->clib_time) + time_to_wait;
do
{
rv = vppcom_epoll_wait (vep_idx, __events, __maxevents, 0);
rv2 = libc_epoll_pwait (__epfd, libc_ev, __maxevents, 1, __ss);
+ if (VCOM_DEBUG == 666)
+ fprintf (stderr, "[%d] vcom_socket_epoll_pwait: "
+ "rv = %d, rv2 = %d, timeout = %f, now = %f\n",
+ getpid (), rv, rv2, timeout, now);
if ((rv > 0) || (rv2 > 0))
{
if (VCOM_DEBUG > 2)
@@ -2949,9 +2955,10 @@ vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
}
goto out;
}
+ if (__timeout != -1)
+ now = clib_time_now (&vsm->clib_time);
}
- while ((__timeout == -1)
- || (clib_time_now (&vsm->clib_time) < timeout));
+ while (now < timeout);
}
out: