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.5.8~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=77bae07bfcbac3c71ccdc741b64542b41fc782f9;p=rspamd.git [CritFix] Fix memory leak in maps scheduling --- diff --git a/src/libutil/map.c b/src/libutil/map.c index 97a982797..e67e0f6fb 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -717,6 +717,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 */ @@ -770,20 +771,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 9e24695b5..4f00c3db2 100644 --- a/src/libutil/map_private.h +++ b/src/libutil/map_private.h @@ -79,7 +79,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) */ @@ -123,6 +122,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;