Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
vppinfra: change fchmod to umask for unix socket
[vpp.git]
/
src
/
vppinfra
/
tw_timer_template.c
diff --git
a/src/vppinfra/tw_timer_template.c
b/src/vppinfra/tw_timer_template.c
index
07e300f
..
6e8a58d
100644
(file)
--- a/
src/vppinfra/tw_timer_template.c
+++ b/
src/vppinfra/tw_timer_template.c
@@
-292,7
+292,7
@@
timer_add (TWT (tw_timer_wheel) * tw, TWT (tw_timer) * t, u64 interval)
* @param u64 interval timer interval in ticks
* @returns handle needed to cancel the timer
*/
* @param u64 interval timer interval in ticks
* @returns handle needed to cancel the timer
*/
-u32
+
__clib_export
u32
TW (tw_timer_start) (TWT (tw_timer_wheel) * tw, u32 user_id, u32 timer_id,
u64 interval)
{
TW (tw_timer_start) (TWT (tw_timer_wheel) * tw, u32 user_id, u32 timer_id,
u64 interval)
{
@@
-349,7
+349,7
@@
int TW (scan_for_handle) (TWT (tw_timer_wheel) * tw, u32 handle)
* @param tw_timer_wheel_t * tw timer wheel object pointer
* @param u32 handle timer cancellation returned by tw_timer_start
*/
* @param tw_timer_wheel_t * tw timer wheel object pointer
* @param u32 handle timer cancellation returned by tw_timer_start
*/
-void TW (tw_timer_stop) (TWT (tw_timer_wheel) * tw, u32 handle)
+
__clib_export
void TW (tw_timer_stop) (TWT (tw_timer_wheel) * tw, u32 handle)
{
TWT (tw_timer) * t;
{
TWT (tw_timer) * t;
@@
-376,7
+376,8
@@
void TW (tw_timer_stop) (TWT (tw_timer_wheel) * tw, u32 handle)
pool_put_index (tw->timers, handle);
}
pool_put_index (tw->timers, handle);
}
-int TW (tw_timer_handle_is_free) (TWT (tw_timer_wheel) * tw, u32 handle)
+__clib_export int
+TW (tw_timer_handle_is_free) (TWT (tw_timer_wheel) * tw, u32 handle)
{
return pool_is_free_index (tw->timers, handle);
}
{
return pool_is_free_index (tw->timers, handle);
}
@@
-387,8
+388,8
@@
int TW (tw_timer_handle_is_free) (TWT (tw_timer_wheel) * tw, u32 handle)
* @param u32 handle timer returned by tw_timer_start
* @param u32 interval timer interval in ticks
*/
* @param u32 handle timer returned by tw_timer_start
* @param u32 interval timer interval in ticks
*/
-void TW (tw_timer_update) (TWT (tw_timer_wheel) * tw, u32 handle,
-
u64 interval)
+__clib_export void
+
TW (tw_timer_update) (TWT (tw_timer_wheel) * tw, u32 handle,
u64 interval)
{
TWT (tw_timer) * t;
t = pool_elt_at_index (tw->timers, handle);
{
TWT (tw_timer) * t;
t = pool_elt_at_index (tw->timers, handle);
@@
-403,7
+404,7
@@
void TW (tw_timer_update) (TWT (tw_timer_wheel) * tw, u32 handle,
* expired timer handles. The callback is optional.
* @param f64 timer_interval_in_seconds
*/
* expired timer handles. The callback is optional.
* @param f64 timer_interval_in_seconds
*/
-void
+
__clib_export
void
TW (tw_timer_wheel_init) (TWT (tw_timer_wheel) * tw,
void *expired_timer_callback,
f64 timer_interval_in_seconds, u32 max_expirations)
TW (tw_timer_wheel_init) (TWT (tw_timer_wheel) * tw,
void *expired_timer_callback,
f64 timer_interval_in_seconds, u32 max_expirations)
@@
-421,10
+422,9
@@
TW (tw_timer_wheel_init) (TWT (tw_timer_wheel) * tw,
}
tw->timer_interval = timer_interval_in_seconds;
tw->ticks_per_second = 1.0 / timer_interval_in_seconds;
}
tw->timer_interval = timer_interval_in_seconds;
tw->ticks_per_second = 1.0 / timer_interval_in_seconds;
- tw->first_expires_tick = ~0ULL;
vec_validate (tw->expired_timer_handles, 0);
vec_validate (tw->expired_timer_handles, 0);
-
_vec_len (tw->expired_timer_handles) = 0
;
+
vec_set_len (tw->expired_timer_handles, 0)
;
for (ring = 0; ring < TW_TIMER_WHEELS; ring++)
{
for (ring = 0; ring < TW_TIMER_WHEELS; ring++)
{
@@
-451,7
+451,7
@@
TW (tw_timer_wheel_init) (TWT (tw_timer_wheel) * tw,
* @brief Free a tw timer wheel template instance
* @param tw_timer_wheel_t * tw timer wheel object pointer
*/
* @brief Free a tw timer wheel template instance
* @param tw_timer_wheel_t * tw timer wheel object pointer
*/
-void TW (tw_timer_wheel_free) (TWT (tw_timer_wheel) * tw)
+
__clib_export
void TW (tw_timer_wheel_free) (TWT (tw_timer_wheel) * tw)
{
int i, j;
tw_timer_wheel_slot_t *ts;
{
int i, j;
tw_timer_wheel_slot_t *ts;
@@
-514,7
+514,7
@@
static inline
u32 slow_wheel_index __attribute__ ((unused));
u32 glacier_wheel_index __attribute__ ((unused));
u32 slow_wheel_index __attribute__ ((unused));
u32 glacier_wheel_index __attribute__ ((unused));
- /*
Shouldn't happen
*/
+ /*
Called too soon to process new timer expirations?
*/
if (PREDICT_FALSE (now < tw->next_run_time))
return callback_vector_arg;
if (PREDICT_FALSE (now < tw->next_run_time))
return callback_vector_arg;
@@
-526,9
+526,17
@@
static inline
/* Remember when we ran, compute next runtime */
tw->next_run_time = (now + tw->timer_interval);
/* Remember when we ran, compute next runtime */
tw->next_run_time = (now + tw->timer_interval);
+ /* First call, or time jumped backwards? */
+ if (PREDICT_FALSE
+ ((tw->last_run_time == 0.0) || (now <= tw->last_run_time)))
+ {
+ tw->last_run_time = now;
+ return callback_vector_arg;
+ }
+
if (callback_vector_arg == 0)
{
if (callback_vector_arg == 0)
{
-
_vec_len (tw->expired_timer_handles) = 0
;
+
vec_set_len (tw->expired_timer_handles, 0)
;
callback_vector = tw->expired_timer_handles;
}
else
callback_vector = tw->expired_timer_handles;
}
else
@@
-803,13
+811,14
@@
static inline
return callback_vector;
}
return callback_vector;
}
-u32 *TW (tw_timer_expire_timers) (TWT (tw_timer_wheel) * tw, f64 now)
+__clib_export u32 *TW (tw_timer_expire_timers) (TWT (tw_timer_wheel) * tw,
+ f64 now)
{
return TW (tw_timer_expire_timers_internal) (tw, now, 0 /* no vector */ );
}
{
return TW (tw_timer_expire_timers_internal) (tw, now, 0 /* no vector */ );
}
-
u32 *TW (tw_timer_expire_timers_vec) (TWT (tw_timer_wheel) * tw, f64 no
w,
- u32 * vec)
+
__clib_export u32 *TW (tw_timer_expire_timers_vec) (TWT (tw_timer_wheel) * t
w,
+
f64 now,
u32 * vec)
{
return TW (tw_timer_expire_timers_internal) (tw, now, vec);
}
{
return TW (tw_timer_expire_timers_internal) (tw, now, vec);
}
@@
-822,7
+831,8
@@
u32 *TW (tw_timer_expire_timers_vec) (TWT (tw_timer_wheel) * tw, f64 now,
* when timers are removed from fast wheel slots.
*/
* when timers are removed from fast wheel slots.
*/
-u32 TW (tw_timer_first_expires_in_ticks) (TWT (tw_timer_wheel) * tw)
+__clib_export u32
+TW (tw_timer_first_expires_in_ticks) (TWT (tw_timer_wheel) * tw)
{
u32 first_expiring_index, fast_ring_index;
i32 delta;
{
u32 first_expiring_index, fast_ring_index;
i32 delta;