diff --git a/Makefile b/Makefile index bc880df2..4b3f63aa 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,7 @@ mingw++: Makefile mongoose.h $(SRCS) $(DOCKER) mdashnet/mingw i686-w64-mingw32-g++ $(SRCS) -W -Wall -Werror -I. $(DEFS) -lwsock32 -o test.exe # Note: for some reason, a binary built with mingw g++, fails to run +linux: IPV6=0 linux: Makefile mongoose.h $(SRCS) $(DOCKER) mdashnet/cc2 gcc $(SRCS) $(CFLAGS) $(LDFLAGS) -o unit_test_gcc $(DOCKER) mdashnet/cc2 ./unit_test_gcc diff --git a/mongoose.c b/mongoose.c index e133eef9..c6ed6572 100644 --- a/mongoose.c +++ b/mongoose.c @@ -263,7 +263,6 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data, // MG_INFO(("d %p %hu %hu", d, d->txnid, dm.txnid)); if (dm.txnid != d->txnid) continue; if (d->c->is_resolving) { - d->c->is_resolving = 0; if (dm.resolved) { char buf[100]; dm.addr.port = d->c->peer.port; // Save port @@ -3345,7 +3344,7 @@ static SOCKET mg_open_listener(const char *url, struct mg_addr *addr) { } if (fd == INVALID_SOCKET) { if (s_err == 0) s_err = MG_SOCK_ERRNO; - MG_ERROR(("Failed to listen on %s, errno %d", url, s_err)); + MG_ERROR(("failed %s, errno %d (%s)", url, s_err, strerror(s_err))); } return fd; @@ -3446,6 +3445,7 @@ void mg_connect_resolved(struct mg_connection *c) { int rc, af = c->peer.is_ip6 ? AF_INET6 : AF_INET; // mg_straddr(&c->peer, buf, sizeof(buf)); c->fd = S2PTR(socket(af, type, 0)); + c->is_resolving = 0; if (FD(c) == INVALID_SOCKET) { mg_error(c, "socket(): %d", MG_SOCK_ERRNO); } else if (c->is_udp) { diff --git a/src/dns.c b/src/dns.c index 268a7287..e7215210 100644 --- a/src/dns.c +++ b/src/dns.c @@ -153,7 +153,6 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data, // MG_INFO(("d %p %hu %hu", d, d->txnid, dm.txnid)); if (dm.txnid != d->txnid) continue; if (d->c->is_resolving) { - d->c->is_resolving = 0; if (dm.resolved) { char buf[100]; dm.addr.port = d->c->peer.port; // Save port diff --git a/src/sock.c b/src/sock.c index fa538c6e..57da8593 100644 --- a/src/sock.c +++ b/src/sock.c @@ -249,7 +249,7 @@ static SOCKET mg_open_listener(const char *url, struct mg_addr *addr) { } if (fd == INVALID_SOCKET) { if (s_err == 0) s_err = MG_SOCK_ERRNO; - MG_ERROR(("Failed to listen on %s, errno %d", url, s_err)); + MG_ERROR(("failed %s, errno %d (%s)", url, s_err, strerror(s_err))); } return fd; @@ -350,6 +350,7 @@ void mg_connect_resolved(struct mg_connection *c) { int rc, af = c->peer.is_ip6 ? AF_INET6 : AF_INET; // mg_straddr(&c->peer, buf, sizeof(buf)); c->fd = S2PTR(socket(af, type, 0)); + c->is_resolving = 0; if (FD(c) == INVALID_SOCKET) { mg_error(c, "socket(): %d", MG_SOCK_ERRNO); } else if (c->is_udp) { diff --git a/test/unit_test.c b/test/unit_test.c index 573dc841..b0b71bd7 100644 --- a/test/unit_test.c +++ b/test/unit_test.c @@ -760,7 +760,7 @@ static void test_http_server(void) { #if MG_ENABLE_IPV6 { - const char *url6 = "http://[::1]:12346"; + const char *url6 = "http://[::1]:12366"; ASSERT(mg_http_listen(&mgr, url6, eh1, NULL) != NULL); ASSERT(fetch(&mgr, buf, url6, "GET /a.txt HTTP/1.0\n\n") == 200); ASSERT(cmpbody(buf, "hello\n") == 0); @@ -1787,8 +1787,8 @@ int main(void) { test_tls(); test_ws(); test_ws_fragmentation(); - test_http_server(); test_http_client(); + test_http_server(); test_http_no_content_length(); test_http_pipeline(); test_http_range();