mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
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>
This commit is contained in:
parent
c834efabd6
commit
0ecefd5bf9
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user