aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/upstream.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-05 14:31:54 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-05 14:31:54 +0000
commit70d859cede253e512d9f968178b3155bf927a68f (patch)
tree2159436373c463cddc657bdd753427a69088dd6c /src/libutil/upstream.c
parenta6a1a8d5aea8439b78645d2dc77b61a898020b7d (diff)
downloadrspamd-70d859cede253e512d9f968178b3155bf927a68f.tar.gz
rspamd-70d859cede253e512d9f968178b3155bf927a68f.zip
[Feature] Allow to add upstream watchers to Lua API
Diffstat (limited to 'src/libutil/upstream.c')
-rw-r--r--src/libutil/upstream.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c
index 90f792bbe..eb88e501a 100644
--- a/src/libutil/upstream.c
+++ b/src/libutil/upstream.c
@@ -36,6 +36,7 @@ struct upstream_addr_elt {
struct upstream_list_watcher {
rspamd_upstream_watch_func func;
+ GFreeFunc dtor;
gpointer ud;
enum rspamd_upstreams_watch_event events_mask;
struct upstream_list_watcher *next, *prev;
@@ -879,6 +880,9 @@ rspamd_upstreams_destroy (struct upstream_list *ups)
}
DL_FOREACH_SAFE (ups->watchers, w, tmp) {
+ if (w->dtor) {
+ w->dtor (w->ud);
+ }
g_free (w);
}
@@ -1178,6 +1182,7 @@ rspamd_upstreams_set_limits (struct upstream_list *ups,
void rspamd_upstreams_add_watch_callback (struct upstream_list *ups,
enum rspamd_upstreams_watch_event events,
rspamd_upstream_watch_func func,
+ GFreeFunc dtor,
gpointer ud)
{
struct upstream_list_watcher *nw;
@@ -1188,6 +1193,7 @@ void rspamd_upstreams_add_watch_callback (struct upstream_list *ups,
nw->func = func;
nw->events_mask = events;
nw->ud = ud;
+ nw->dtor = dtor;
DL_APPEND (ups->watchers, nw);
}