- syslog(LOG_WARNING, "dnssd_clientstub ConnectionResponse: sdr->op != connection_request");
- rref->AppCallback(rref->sdr, rref, 0, kDNSServiceErr_Unknown, rref->AppContext);
+ DNSRecordRef rec;
+ for (rec = sdr->rec; rec; rec = rec->recnext)
+ {
+ if (rec->uid.u32[0] == cbh->ipc_hdr.client_context.u32[0] && rec->uid.u32[1] == cbh->ipc_hdr.client_context.u32[1])
+ break;
+ }
+ // The record might have been freed already and hence not an
+ // error if the record is not found.
+ if (!rec)
+ {
+ syslog(LOG_INFO, "ConnectionResponse: Record not found");
+ return;
+ }
+ if (rec->sdr != sdr)
+ {
+ syslog(LOG_WARNING, "ConnectionResponse: Record sdr mismatch: rec %p sdr %p", rec->sdr, sdr);
+ return;
+ }
+
+ if (sdr->op == connection_request)
+ {
+ rec->AppCallback(rec->sdr, rec, cbh->cb_flags, cbh->cb_err, rec->AppContext);
+ }
+ else
+ {
+ syslog(LOG_WARNING, "dnssd_clientstub ConnectionResponse: sdr->op != connection_request");
+ rec->AppCallback(rec->sdr, rec, 0, kDNSServiceErr_Unknown, rec->AppContext);
+ }
+ // MUST NOT touch sdr after invoking AppCallback -- client is allowed to dispose it from within callback function