- finish(r, -1, AVAHI_PROTO_UNSPEC, AVAHI_RESOLVER_TIMEOUT, NULL);
+ assert(record->key->type == AVAHI_DNS_TYPE_PTR);
+
+ if (event == AVAHI_BROWSER_NEW) {
+
+ if (r->interface > 0 && interface != r->interface)
+ return;
+
+ if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol)
+ return;
+
+ if (r->interface <= 0)
+ r->interface = interface;
+
+ if (r->protocol == AVAHI_PROTO_UNSPEC)
+ r->protocol = protocol;
+
+ if (!r->ptr_record) {
+ r->ptr_record = avahi_record_ref(record);
+
+ finish(r, AVAHI_RESOLVER_FOUND);
+ }
+
+ } else {
+
+ assert(event == AVAHI_BROWSER_REMOVE);
+
+ if (r->ptr_record && avahi_record_equal_no_ttl(record, r->ptr_record)) {
+ avahi_record_unref(r->ptr_record);
+ r->ptr_record = NULL;
+
+ /** Look for a replacement */
+ avahi_s_record_browser_restart(r->record_browser);
+ start_timeout(r);
+ }
+ }