From: Vsevolod Stakhov Date: Sun, 7 May 2017 13:47:41 +0000 (+0100) Subject: [CritFix] Fix memory leak in maps scheduling X-Git-Tag: 1.6.0~254 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c44fc67ed4073559a2b7d72a9d45a8dab3d319e3;p=rspamd.git [CritFix] Fix memory leak in maps scheduling --- diff --git a/src/libutil/map.c b/src/libutil/map.c index 30617689c..c6a7189a8 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -800,6 +800,7 @@ rspamd_map_periodic_dtor (struct map_periodic_cbdata *periodic) map = periodic->map; msg_debug_map ("periodic dtor %p", periodic); + event_del (&periodic->ev); if (periodic->need_modify) { /* We are done */ @@ -853,20 +854,20 @@ rspamd_map_schedule_periodic (struct rspamd_map *map, REF_INIT_RETAIN (cbd, rspamd_map_periodic_dtor); if (initial) { - evtimer_set (&map->ev, rspamd_map_periodic_callback, cbd); - event_base_set (map->ev_base, &map->ev); + evtimer_set (&cbd->ev, rspamd_map_periodic_callback, cbd); + event_base_set (map->ev_base, &cbd->ev); } else { - evtimer_del (&map->ev); - evtimer_set (&map->ev, rspamd_map_periodic_callback, cbd); - event_base_set (map->ev_base, &map->ev); + evtimer_set (&cbd->ev, rspamd_map_periodic_callback, cbd); + event_base_set (map->ev_base, &cbd->ev); } jittered_sec = rspamd_time_jitter (timeout, 0); - msg_debug_map ("schedule new periodic event %p in %.2f seconds", cbd, jittered_sec); + msg_debug_map ("schedule new periodic event %p in %.2f seconds", + cbd, jittered_sec); double_to_tv (jittered_sec, &map->tv); - evtimer_add (&map->ev, &map->tv); + evtimer_add (&cbd->ev, &map->tv); } static void diff --git a/src/libutil/map_private.h b/src/libutil/map_private.h index f59b3b6c1..abb4ef613 100644 --- a/src/libutil/map_private.h +++ b/src/libutil/map_private.h @@ -81,7 +81,6 @@ struct rspamd_map { gchar *description; gchar *name; guint32 id; - struct event ev; struct timeval tv; gdouble poll_timeout; /* Shared lock for temporary disabling of map reading (e.g. when this map is written by UI) */ @@ -131,6 +130,7 @@ enum rspamd_map_http_stage { struct map_periodic_cbdata { struct rspamd_map *map; struct map_cb_data cbdata; + struct event ev; gboolean need_modify; gboolean errored; guint cur_backend;