From cd2b8b467b218dfdd2d5124ad2d835161f3a2b1a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 3 Mar 2018 21:56:15 +0100 Subject: [PATCH] handle case where resolver operation is cancelled during success callback --- src/util/resolver_api.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index bd46b4fbb..b92fd6a02 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c @@ -500,11 +500,13 @@ handle_response (void *cls, GNUNET_free (nret); } /* finally, make termination call */ - rh->name_callback (rh->cls, - NULL); + if (GNUNET_SYSERR != rh->was_transmitted) + rh->name_callback (rh->cls, + NULL); } - if (NULL != rh->addr_callback) - rh->addr_callback (rh->cls, + if ( (NULL != rh->addr_callback) && + (GNUNET_SYSERR != rh->was_transmitted) ) + rh->addr_callback (rh->cls, NULL, 0); } @@ -637,6 +639,7 @@ numeric_resolution (void *cls) (const struct sockaddr *) &v4, sizeof (v4)); if ( (rh->af == AF_UNSPEC) && + (GNUNET_SYSERR != rh->was_transmitted) && (1 == inet_pton (AF_INET6, hostname, &v6.sin6_addr)) ) @@ -646,9 +649,10 @@ numeric_resolution (void *cls) (const struct sockaddr *) &v6, sizeof (v6)); } - rh->addr_callback (rh->cls, - NULL, - 0); + if (GNUNET_SYSERR != rh->was_transmitted) + rh->addr_callback (rh->cls, + NULL, + 0); GNUNET_free (rh); return; } @@ -661,9 +665,10 @@ numeric_resolution (void *cls) rh->addr_callback (rh->cls, (const struct sockaddr *) &v6, sizeof (v6)); - rh->addr_callback (rh->cls, - NULL, - 0); + if (GNUNET_SYSERR != rh->was_transmitted) + rh->addr_callback (rh->cls, + NULL, + 0); GNUNET_free (rh); return; } @@ -725,9 +730,10 @@ loopback_resolution (void *cls) GNUNET_break (0); break; } - rh->addr_callback (rh->cls, - NULL, - 0); + if (GNUNET_SYSERR != rh->was_transmitted) + rh->addr_callback (rh->cls, + NULL, + 0); LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished resolving hostname `%s'.\n", (const char *) &rh[1]); -- 2.25.1