BAN: Don't schedule check_klines for 0 seconds in the future.

When receiving bans from a bursting server, if kline_delay is set to 0
(the default), rb_event_addonce will be called to schedule an event for
0 seconds in the future. While this works fine for the fallback
rb_event_run function, the epoll implementation ends up scheduling a
timerfd for the event in the past, which is then never executed.

While fixing this, I also made rb_event_add and rb_event_addonce reject
attempts to add events scheduled for 0 seconds in the future; they're
instead rewritten to run 1 second in the future.
This commit is contained in:
Keith Buck 2014-08-17 09:06:01 +00:00
parent 1c38b9def0
commit 8db50c03e6
2 changed files with 12 additions and 1 deletions

View file

@ -88,6 +88,11 @@ rb_event_find(EVH * func, void *arg)
struct ev_entry *
rb_event_add(const char *name, EVH * func, void *arg, time_t when)
{
if (rb_unlikely(when <= 0)) {
rb_lib_log("rb_event_add: tried to schedule %s event with a delay of "
"%d seconds", name, (int) when);
when = 1;
}
struct ev_entry *ev;
ev = rb_malloc(sizeof(struct ev_entry));
ev->func = func;
@ -109,6 +114,11 @@ rb_event_add(const char *name, EVH * func, void *arg, time_t when)
struct ev_entry *
rb_event_addonce(const char *name, EVH * func, void *arg, time_t when)
{
if (rb_unlikely(when <= 0)) {
rb_lib_log("rb_event_addonce: tried to schedule %s event to run in "
"%d seconds", name, (int) when);
when = 1;
}
struct ev_entry *ev;
ev = rb_malloc(sizeof(struct ev_entry));
ev->func = func;

View file

@ -291,7 +291,8 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
if(kline_queued == 0)
{
rb_event_addonce("check_klines", check_klines_event, NULL,
ConfigFileEntry.kline_delay);
ConfigFileEntry.kline_delay ?
ConfigFileEntry.kline_delay : 1);
kline_queued = 1;
}
}