diff options
author | Volker Lendecke <vl@samba.org> | 2016-08-31 15:39:59 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2016-10-05 00:06:21 +0200 |
commit | 0ecefd5bf91ae8297569dc862d7259e942d895fe (patch) | |
tree | f3560da31657b7251d5bc4181e3cbdc7bee2c21b /lib/tevent | |
parent | c834efabd685198c570503bfc8394ff80899cef5 (diff) | |
download | samba-0ecefd5bf91ae8297569dc862d7259e942d895fe.tar.gz |
tevent: Add tevent_update_timer()
This will be a quicker way to time out sending sockets in messaging_dgm. Right
now cleanup of out-sockets is a bit coarse. The ideal would be to kill a socket
after being idle n seconds. This would mean to free and re-install a timer on
every packet. tevent_update_timer will be quite a bit cheaper.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/tevent')
-rw-r--r-- | lib/tevent/ABI/tevent-0.9.30.sigs | 1 | ||||
-rw-r--r-- | lib/tevent/tevent.h | 10 | ||||
-rw-r--r-- | lib/tevent/tevent_timed.c | 18 |
3 files changed, 29 insertions, 0 deletions
diff --git a/lib/tevent/ABI/tevent-0.9.30.sigs b/lib/tevent/ABI/tevent-0.9.30.sigs index 9b8bfa1cedd..66a450e1545 100644 --- a/lib/tevent/ABI/tevent-0.9.30.sigs +++ b/lib/tevent/ABI/tevent-0.9.30.sigs @@ -92,5 +92,6 @@ tevent_timeval_set: struct timeval (uint32_t, uint32_t) tevent_timeval_until: struct timeval (const struct timeval *, const struct timeval *) tevent_timeval_zero: struct timeval (void) tevent_trace_point_callback: void (struct tevent_context *, enum tevent_trace_point) +tevent_update_timer: void (struct tevent_timer *, struct timeval) tevent_wakeup_recv: bool (struct tevent_req *) tevent_wakeup_send: struct tevent_req *(TALLOC_CTX *, struct tevent_context *, struct timeval) diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h index 7de04d03896..bb23257a965 100644 --- a/lib/tevent/tevent.h +++ b/lib/tevent/tevent.h @@ -252,6 +252,16 @@ struct tevent_timer *_tevent_add_timer(struct tevent_context *ev, #handler, __location__) #endif +/** + * @brief Set the time a tevent_timer fires + * + * @param[in] te The timer event to reset + * + * @param[in] next_event Timeval specifying the absolute time to fire this + * event. This is not an offset. + */ +void tevent_update_timer(struct tevent_timer *te, struct timeval next_event); + #ifdef DOXYGEN /** * Initialize an immediate event object diff --git a/lib/tevent/tevent_timed.c b/lib/tevent/tevent_timed.c index bb0160c41e4..92f3ed17b26 100644 --- a/lib/tevent/tevent_timed.c +++ b/lib/tevent/tevent_timed.c @@ -284,6 +284,24 @@ struct tevent_timer *tevent_common_add_timer_v2(struct tevent_context *ev, true); } +void tevent_update_timer(struct tevent_timer *te, struct timeval next_event) +{ + struct tevent_context *ev = te->event_ctx; + + if (ev->last_zero_timer == te) { + te->event_ctx->last_zero_timer = DLIST_PREV(te); + } + DLIST_REMOVE(ev->timer_events, te); + + te->next_event = next_event; + + /* + * Not doing the zero_timer optimization. This is for new code + * that should know about immediates. + */ + tevent_common_insert_timer(ev, te, false); +} + /* do a single event loop using the events defined in ev |