#include <import/ebtree-t.h>
#include <haproxy/api-t.h>
+#include <haproxy/event_hdl-t.h>
#include <haproxy/regex-t.h>
#include <haproxy/sample_data-t.h>
#include <haproxy/thread-t.h>
unsigned long long entry_cnt; /* the total number of entries */
THREAD_ALIGN(64);
__decl_thread(HA_RWLOCK_T lock); /* Lock used to protect pat ref elements */
+ event_hdl_sub_list e_subs; /* event_hdl: pat_ref's subscribers list (atomically updated) */
};
/* This is a part of struct pat_ref. Each entry contains one pattern and one
#include <string.h>
#include <haproxy/api.h>
+#include <haproxy/event_hdl.h>
#include <haproxy/pattern-t.h>
#include <haproxy/sample-t.h>
*/
static inline int pat_ref_commit(struct pat_ref *ref, unsigned int gen)
{
- if ((int)(gen - ref->curr_gen) > 0)
+ if ((int)(gen - ref->curr_gen) > 0) {
ref->curr_gen = gen;
+ event_hdl_publish(&ref->e_subs, EVENT_HDL_SUB_PAT_REF_COMMIT, NULL);
+ }
return gen - ref->curr_gen;
}
/* delete pattern from reference */
list_for_each_entry_safe(elt, safe, &ref->head, list) {
if (elt == refelt) {
+ event_hdl_publish(&ref->e_subs, EVENT_HDL_SUB_PAT_REF_DEL, NULL);
pat_ref_delete_by_ptr(ref, elt);
return 1;
}
found = 1;
}
+ if (found)
+ event_hdl_publish(&ref->e_subs, EVENT_HDL_SUB_PAT_REF_DEL, NULL);
+
return found;
}
memprintf(err, "entry not found");
return 0;
}
+
+ if (gen == ref->curr_gen) // gen cannot be uninitialized here
+ event_hdl_publish(&ref->e_subs, EVENT_HDL_SUB_PAT_REF_SET, NULL);
+
return 1;
}
ref->ebmb_root = EB_ROOT;
LIST_INIT(&ref->pat);
HA_RWLOCK_INIT(&ref->lock);
+ event_hdl_sub_list_init(&ref->e_subs);
return ref;
}
{
ha_free(&ref->reference);
ha_free(&ref->display);
+ event_hdl_sub_list_destroy(&ref->e_subs);
free(ref);
}
} else
memprintf(err, "out of memory error");
+ /* ignore if update requires committing to be seen */
+ if (elt && gen == ref->curr_gen)
+ event_hdl_publish(&ref->e_subs, EVENT_HDL_SUB_PAT_REF_ADD, NULL);
+
return elt;
}
list_for_each_entry(expr, &ref->pat, list)
HA_RWLOCK_WRUNLOCK(PATEXP_LOCK, &expr->lock);
+ /* only publish when we're done and if curr_gen was impacted by the
+ * purge
+ */
+ if (done && ref->curr_gen - from <= to - from)
+ event_hdl_publish(&ref->e_subs, EVENT_HDL_SUB_PAT_REF_CLEAR, NULL);
+
return done;
}