Ticket #198: patch.txt

File patch.txt, 2.1 KB (added by yavor, 4 years ago)

patch

Line 
1Index: entry.c
2===================================================================
3--- entry.c (revision 5067)
4+++ entry.c (working copy)
5@@ -52,6 +52,8 @@
6 #include "rr-util.h"
7 #include "domain-util.h"
8 
9+void avahi_transfer_zone_to_cache(AvahiServer * s);
10+
11 static void transport_flags_from_domain(AvahiServer *s, AvahiPublishFlags *flags, const char *domain) {
12     assert(flags);
13     assert(domain);
14@@ -77,6 +79,8 @@
15     assert(s);
16     assert(e);
17 
18+    avahi_transfer_zone_to_cache(s);
19+
20     avahi_goodbye_entry(s, e, 1, 1);
21 
22     /* Remove from linked list */
23@@ -563,6 +567,25 @@
24     return avahi_string_list_add_printf(strlst, AVAHI_SERVICE_COOKIE"=%u", s->local_service_cookie);
25 }
26 
27+void avahi_transfer_zone_to_cache(AvahiServer * s)
28+{
29+    /* Major Assumptions:
30+       - The index of the "lo" interface is always 1.
31+    */
32+    AvahiAddress a;
33+    avahi_address_parse("127.0.0.1", AVAHI_PROTO_INET, &a);
34+    AvahiInterface * i = avahi_interface_monitor_get_interface(s->monitor, 1, AVAHI_PROTO_INET);
35+
36+    AvahiEntry *e;
37+    avahi_cache_flush(i->cache);
38+    for (e = s->entries; e; e = e->entries_next) {
39+       if (e->dead) {
40+           continue;
41+       }
42+       avahi_cache_update(i->cache, e->record, 1, &a);
43+    }
44+}
45+
46 static int server_add_service_strlst_nocopy(
47     AvahiServer *s,
48     AvahiSEntryGroup *g,
49@@ -665,6 +688,8 @@
50         goto fail;
51     }
52 
53+    avahi_transfer_zone_to_cache(s);
54+
55 fail:
56     if (ret != AVAHI_OK && !(flags & AVAHI_PUBLISH_UPDATE)) {
57         if (srv_entry)
58Index: probe-sched.c
59===================================================================
60--- probe-sched.c   (revision 5067)
61+++ probe-sched.c   (working copy)
62@@ -216,6 +216,8 @@
63     return 1;
64 }
65 
66+void avahi_transfer_zone_to_cache(AvahiServer * s);
67+
68 static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
69     AvahiProbeJob *pj = data, *next;
70     AvahiProbeScheduler *s;
71@@ -224,6 +226,8 @@
72 
73     assert(pj);
74     s = pj->scheduler;
75+   
76+    avahi_transfer_zone_to_cache(s->interface->monitor->server);
77 
78     if (pj->done) {
79         /* Lets remove it  from the history */