Log ms in test_sntp()

This commit is contained in:
Sergey Lyubka committed 2022-05-15 19:31:29 +01:00
1 parent f5fd176b35
commit 7721b074e6
3 files changed
+11 -8

No files matched your search

+5 -4
View File
@@ -3446,7 +3446,8 @@ static void close_conn(struct mg_connection *c) {
} }
static void setsockopts(struct mg_connection *c) { static void setsockopts(struct mg_connection *c) {
#if MG_ARCH == MG_ARCH_FREERTOS_TCP || MG_ARCH == MG_ARCH_AZURERTOS || MG_ARCH == MG_ARCH_TIRTOS #if MG_ARCH == MG_ARCH_FREERTOS_TCP || MG_ARCH == MG_ARCH_AZURERTOS || \
MG_ARCH == MG_ARCH_TIRTOS
(void) c; (void) c;
#else #else
int on = 1; int on = 1;
@@ -3482,13 +3483,12 @@ void mg_connect_resolved(struct mg_connection *c) {
if ((rc = connect(FD(c), &usa.sa, slen)) == 0) { if ((rc = connect(FD(c), &usa.sa, slen)) == 0) {
mg_call(c, MG_EV_CONNECT, NULL); mg_call(c, MG_EV_CONNECT, NULL);
} else if (mg_sock_would_block()) { } else if (mg_sock_would_block()) {
MG_DEBUG(("%lu %p connect in progress...", c->id, c->fd));
c->is_connecting = 1; c->is_connecting = 1;
} else { } else {
mg_error(c, "connect: %d", MG_SOCK_ERRNO); mg_error(c, "connect: %d", MG_SOCK_ERRNO);
} }
} }
(void)rc;
MG_DEBUG(("%lu %p", c->id, c->fd));
} }
static SOCKET raccept(SOCKET sock, union usa *usa, socklen_t len) { static SOCKET raccept(SOCKET sock, union usa *usa, socklen_t len) {
@@ -3513,7 +3513,8 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
if (MG_SOCK_ERRNO != EAGAIN) if (MG_SOCK_ERRNO != EAGAIN)
#endif #endif
MG_ERROR(("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO)); MG_ERROR(("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO));
#if (MG_ARCH != MG_ARCH_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP) && (MG_ARCH != MG_ARCH_TIRTOS) #if (MG_ARCH != MG_ARCH_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP) && \
(MG_ARCH != MG_ARCH_TIRTOS)
} else if ((long) fd >= FD_SETSIZE) { } else if ((long) fd >= FD_SETSIZE) {
MG_ERROR(("%ld > %ld", (long) fd, (long) FD_SETSIZE)); MG_ERROR(("%ld > %ld", (long) fd, (long) FD_SETSIZE));
closesocket(fd); closesocket(fd);
+5 -4
View File
@@ -312,7 +312,8 @@ static void close_conn(struct mg_connection *c) {
} }
static void setsockopts(struct mg_connection *c) { static void setsockopts(struct mg_connection *c) {
#if MG_ARCH == MG_ARCH_FREERTOS_TCP || MG_ARCH == MG_ARCH_AZURERTOS || MG_ARCH == MG_ARCH_TIRTOS #if MG_ARCH == MG_ARCH_FREERTOS_TCP || MG_ARCH == MG_ARCH_AZURERTOS || \
MG_ARCH == MG_ARCH_TIRTOS
(void) c; (void) c;
#else #else
int on = 1; int on = 1;
@@ -348,13 +349,12 @@ void mg_connect_resolved(struct mg_connection *c) {
if ((rc = connect(FD(c), &usa.sa, slen)) == 0) { if ((rc = connect(FD(c), &usa.sa, slen)) == 0) {
mg_call(c, MG_EV_CONNECT, NULL); mg_call(c, MG_EV_CONNECT, NULL);
} else if (mg_sock_would_block()) { } else if (mg_sock_would_block()) {
MG_DEBUG(("%lu %p connect in progress...", c->id, c->fd));
c->is_connecting = 1; c->is_connecting = 1;
} else { } else {
mg_error(c, "connect: %d", MG_SOCK_ERRNO); mg_error(c, "connect: %d", MG_SOCK_ERRNO);
} }
} }
(void)rc;
MG_DEBUG(("%lu %p", c->id, c->fd));
} }
static SOCKET raccept(SOCKET sock, union usa *usa, socklen_t len) { static SOCKET raccept(SOCKET sock, union usa *usa, socklen_t len) {
@@ -379,7 +379,8 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
if (MG_SOCK_ERRNO != EAGAIN) if (MG_SOCK_ERRNO != EAGAIN)
#endif #endif
MG_ERROR(("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO)); MG_ERROR(("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO));
#if (MG_ARCH != MG_ARCH_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP) && (MG_ARCH != MG_ARCH_TIRTOS) #if (MG_ARCH != MG_ARCH_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP) && \
(MG_ARCH != MG_ARCH_TIRTOS)
} else if ((long) fd >= FD_SETSIZE) { } else if ((long) fd >= FD_SETSIZE) {
MG_ERROR(("%ld > %ld", (long) fd, (long) FD_SETSIZE)); MG_ERROR(("%ld > %ld", (long) fd, (long) FD_SETSIZE));
closesocket(fd); closesocket(fd);
+1
View File
@@ -300,6 +300,7 @@ static void test_sntp(void) {
ASSERT(c != NULL); ASSERT(c != NULL);
ASSERT(c->is_udp == 1); ASSERT(c->is_udp == 1);
for (i = 0; i < 500 && ms == 0; i++) mg_mgr_poll(&mgr, 10); for (i = 0; i < 500 && ms == 0; i++) mg_mgr_poll(&mgr, 10);
MG_DEBUG(("ms: %lld", ms));
ASSERT(ms > 0); ASSERT(ms > 0);
mg_mgr_free(&mgr); mg_mgr_free(&mgr);