Skip to content

Commit

Permalink
mdns: stop polling as soon as we reach resolve_cb
Browse files Browse the repository at this point in the history
  • Loading branch information
pkova committed Sep 5, 2023
1 parent 43e9207 commit 390735c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pkg/vere/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ static void getaddrinfo_cb(uv_getaddrinfo_t* req, int status, struct addrinfo* r

if (status < 0) {
u3l_log("mdns: getaddrinfo error: %s", uv_strerror(status));
uv_poll_stop(payload->poll);
c3_free(payload->poll);
DNSServiceRefDeallocate(payload->sref);
c3_free(payload);
c3_free(req);
Expand All @@ -33,8 +31,6 @@ static void getaddrinfo_cb(uv_getaddrinfo_t* req, int status, struct addrinfo* r
payload->cb(payload->who, addr->sin_addr.s_addr, payload->port, payload->context);

c3_free(payload->who);
uv_poll_stop(payload->poll);
c3_free(payload->poll);
uv_freeaddrinfo(res);
c3_free(req);
DNSServiceRefDeallocate(payload->sref);
Expand All @@ -55,10 +51,11 @@ static void resolve_cb(DNSServiceRef sref,
{
mdns_payload* payload = (mdns_payload*)context;

uv_poll_stop(payload->poll);
c3_free(payload->poll);

if (err != kDNSServiceErr_NoError) {
u3l_log("mdns: dns resolve error %d", err);
uv_poll_stop(payload->poll);
c3_free(payload->poll);
c3_free(payload);
DNSServiceRefDeallocate(sref);
return;
Expand All @@ -71,8 +68,6 @@ static void resolve_cb(DNSServiceRef sref,

if (who == NULL) {
u3l_log("mdns: invalid domain name");
uv_poll_stop(payload->poll);
c3_free(payload->poll);
c3_free(payload);
DNSServiceRefDeallocate(sref);
return;
Expand All @@ -95,8 +90,6 @@ static void resolve_cb(DNSServiceRef sref,

if (error < 0) {
u3l_log("mdns: getaddrinfo error: %s\n", uv_strerror(error));
uv_poll_stop(payload->poll);
c3_free(payload->poll);
c3_free(payload);
c3_free(req);
DNSServiceRefDeallocate(sref);
Expand Down

0 comments on commit 390735c

Please sign in to comment.