]> code.delx.au - gnu-emacs/commitdiff
Wait for async DNS to complete before freeing resources
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 29 Feb 2016 03:20:09 +0000 (14:20 +1100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 29 Feb 2016 03:20:09 +0000 (14:20 +1100)
* src/process.c (Fdelete_process): Wait for async DNS to
complete before freeing the data structures it needs.

src/process.c

index a3212445cded9f35f0915b656ecbbed18b66ef19..d83e2d2c51ff29042c481228ed8bfbdf6fefaf32 100644 (file)
@@ -845,8 +845,24 @@ nil, indicating the current buffer's process.  */)
 #ifdef HAVE_GETADDRINFO_A
   if (p->dns_request)
     {
+      int ret;
+
       gai_cancel (p->dns_request);
-      free_dns_request (process);
+      ret = gai_error (p->dns_request);
+      if (ret == EAI_CANCELED || ret == 0)
+       free_dns_request (process);
+      else
+       {
+         /* If we're called during shutdown, we don't really about
+            freeing all the resources.  Otherwise wait until
+            completion, and then free the request. */
+         if (! inhibit_sentinels)
+           {
+             gai_suspend ((const struct gaicb * const*)&p->dns_request,
+                          1, NULL);
+             free_dns_request (process);
+           }
+       }
     }
 #endif