From d665d9e90eb8161429da3273b448dfe8654318b9 Mon Sep 17 00:00:00 2001
From: Deomid Ryabkov <rojer@cesanta.com>
Date: Mon, 30 Nov 2015 12:37:47 +0000
Subject: [PATCH] Always Be Closing

    PUBLISHED_FROM=29ca7cdd9024790bd75892f9f67b3f83a6bd00d1
---
 mongoose.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mongoose.c b/mongoose.c
index 05bdee5c9..238f79619 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -1905,9 +1905,7 @@ static void mg_destroy_conn(struct mg_connection *conn) {
 
 void mg_close_conn(struct mg_connection *conn) {
   DBG(("%p %lu", conn, conn->flags));
-  if (!(conn->flags & MG_F_CONNECTING)) {
-    mg_call(conn, NULL, MG_EV_CLOSE, NULL);
-  }
+  mg_call(conn, NULL, MG_EV_CLOSE, NULL);
   mg_remove_conn(conn);
   mg_destroy_conn(conn);
 }
@@ -2550,6 +2548,7 @@ static void resolve_cb(struct mg_dns_message *msg, void *data) {
    * If we get there was no MG_DNS_A_RECORD in the answer
    */
   mg_call(nc, NULL, MG_EV_CONNECT, &failure);
+  mg_call(nc, NULL, MG_EV_CLOSE, NULL);
   mg_destroy_conn(nc);
 }
 #endif
-- 
GitLab