handle case where resolver operation is cancelled during success callback
authorChristian Grothoff <christian@grothoff.org>
Sat, 3 Mar 2018 20:56:15 +0000 (21:56 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sat, 3 Mar 2018 20:56:15 +0000 (21:56 +0100)
src/util/resolver_api.c

index bd46b4fbb237bfebb61d4ad9f20b5268811cdcca..b92fd6a02dd0c127358a4fa002d43cb647724602 100644 (file)
@@ -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]);