summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-01-29 21:28:16 -0800
committerDamjan Marion <dmarion@me.com>2019-01-30 09:06:30 +0000
commit4dee8cdb4ebcf7a7c11ae1ca67427d787b7e6cd4 (patch)
tree676c542ad61d97790ef5a8bdddfe4924d3555a8b /src
parent653cd2dc46cf8d4e4d0c4d72103916a8d2734a86 (diff)
ldp: initialize clib time
Change-Id: Ie598443f024a677a9c6938b3f3634960fd712b09 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vcl/ldp.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c
index ab4cfbfa257..f3ac3107a50 100644
--- a/src/vcl/ldp.c
+++ b/src/vcl/ldp.c
@@ -261,7 +261,12 @@ ldp_init (void)
}
}
- clib_time_init (&ldpw->clib_time);
+ /* *INDENT-OFF* */
+ pool_foreach (ldpw, ldp->workers, ({
+ clib_memset (&ldpw->clib_time, 0, sizeof (ldpw->clib_time));
+ }));
+ /* *INDENT-ON* */
+
LDBG (0, "LDP initialization: done!");
return 0;
@@ -668,6 +673,9 @@ ldp_pselect (int nfds, fd_set * __restrict readfds,
return -1;
}
+ if (PREDICT_FALSE (ldpw->clib_time.init_cpu_time == 0))
+ clib_time_init (&ldpw->clib_time);
+
if (timeout)
{
time_out = (timeout->tv_sec == 0 && timeout->tv_nsec == 0) ?
@@ -2165,6 +2173,8 @@ ldp_epoll_pwait (int epfd, struct epoll_event *events, int maxevents,
return -1;
}
+ if (PREDICT_FALSE (ldpw->clib_time.init_cpu_time == 0))
+ clib_time_init (&ldpw->clib_time);
time_to_wait = ((timeout >= 0) ? (double) timeout / 1000 : 0);
max_time = clib_time_now (&ldpw->clib_time) + time_to_wait;
@@ -2232,14 +2242,15 @@ poll (struct pollfd *fds, nfds_t nfds, int timeout)
int rv, i, n_revents = 0;
vls_handle_t vlsh;
vcl_poll_t *vp;
- double wait_for_time;
+ double max_time;
LDBG (3, "fds %p, nfds %d, timeout %d", fds, nfds, timeout);
- if (timeout >= 0)
- wait_for_time = (f64) timeout / 1000;
- else
- wait_for_time = -1;
+ if (PREDICT_FALSE (ldpw->clib_time.init_cpu_time == 0))
+ clib_time_init (&ldpw->clib_time);
+
+ max_time = (timeout >= 0) ? (f64) timeout / 1000 : 0;
+ max_time += clib_time_now (&ldpw->clib_time);
for (i = 0; i < nfds; i++)
{
@@ -2299,8 +2310,7 @@ poll (struct pollfd *fds, nfds_t nfds, int timeout)
goto done;
}
}
- while ((wait_for_time == -1) ||
- (clib_time_now (&ldpw->clib_time) < wait_for_time));
+ while ((timeout < 0) || (clib_time_now (&ldpw->clib_time) < max_time));
rv = 0;
done: