MinGW
[oweals/gnunet.git] / src / util / connection.c
index 10f53dcf9fe6d63a1139a212bf8510d37b88e380..22a75691bead5905575b796a9edb748d8c723f8b 100644 (file)
@@ -931,11 +931,6 @@ void
 GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock,
                           int finish_pending_write)
 {
-  if ((sock->write_buffer_off == 0) && (sock->dns_active != NULL))
-    {
-      GNUNET_RESOLVER_request_cancel (sock->dns_active);
-      sock->dns_active = NULL;
-    }
   if (GNUNET_NO == finish_pending_write)
     {
       if (sock->write_task != GNUNET_SCHEDULER_NO_TASK)
@@ -943,8 +938,14 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock,
          GNUNET_SCHEDULER_cancel (sock->sched,
                                   sock->write_task);
          sock->write_task = GNUNET_SCHEDULER_NO_TASK;
+         sock->write_buffer_off = 0;
        }
     }
+  if ((sock->write_buffer_off == 0) && (sock->dns_active != NULL))
+    {
+      GNUNET_RESOLVER_request_cancel (sock->dns_active);
+      sock->dns_active = NULL;
+    }
   GNUNET_assert (sock->sched != NULL);
   GNUNET_SCHEDULER_add_now (sock->sched,
                            &destroy_continuation, sock);