mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-28 07:28:13 +08:00
Tiny refactoring - move clearance of the c->is_resolving flag to the mg_connect_resolved()
This commit is contained in:
parent
c579b73f75
commit
507935d067
1
Makefile
1
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
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user