if (s->need_browser_cleanup)
avahi_browser_cleanup(s);
+
+ if (s->cleanup_time_event) {
+ avahi_time_event_free(s->cleanup_time_event);
+ s->cleanup_time_event = NULL;
+ }
}
static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiRecord *r, AvahiPublishFlags flags) {
return g;
}
+static void cleanup_time_event_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* userdata) {
+ AvahiServer *s = userdata;
+
+ assert(s);
+
+ avahi_cleanup_dead_entries(s);
+}
+
+static void schedule_cleanup(AvahiServer *s) {
+ struct timeval tv;
+
+ assert(s);
+
+ if (!s->cleanup_time_event)
+ s->cleanup_time_event = avahi_time_event_new(s->time_event_queue, avahi_elapse_time(&tv, 1000, 0), &cleanup_time_event_callback, s);
+}
+
void avahi_s_entry_group_free(AvahiSEntryGroup *g) {
AvahiEntry *e;
g->server->need_group_cleanup = 1;
g->server->need_entry_cleanup = 1;
- avahi_cleanup_dead_entries(g->server);
+ schedule_cleanup(g->server);
}
static void entry_group_commit_real(AvahiSEntryGroup *g) {
avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_UNCOMMITED);
- avahi_cleanup_dead_entries(g->server);
+ schedule_cleanup(g->server);
}
int avahi_entry_is_commited(AvahiEntry *e) {
int need_entry_cleanup, need_group_cleanup, need_browser_cleanup;
+ /* Used for scheduling RR cleanup */
+ AvahiTimeEvent *cleanup_time_event;
+
AvahiTimeEventQueue *time_event_queue;
char *host_name, *host_name_fqdn, *domain_name;
s->need_entry_cleanup = 0;
s->need_group_cleanup = 0;
s->need_browser_cleanup = 0;
+ s->cleanup_time_event = NULL;
s->hinfo_entry_group = NULL;
s->browse_domain_entry_group = NULL;
s->error = AVAHI_OK;
avahi_wide_area_engine_free(s->wide_area_lookup_engine);
avahi_multicast_lookup_engine_free(s->multicast_lookup_engine);
+ if (s->cleanup_time_event)
+ avahi_time_event_free(s->cleanup_time_event);
+
avahi_time_event_queue_free(s->time_event_queue);
/* Free watches */