mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-27 20:59:00 +08:00
Log ms in test_sntp()
This commit is contained in:
parent
f5fd176b35
commit
7721b074e6
15
mongoose.c
15
mongoose.c
@ -3325,9 +3325,9 @@ static void mg_set_non_blocking_mode(SOCKET fd) {
|
||||
int status = 0;
|
||||
int res = SockStatus(fd, FDSTATUS_SEND, &status);
|
||||
if (res == 0 && status > 0) {
|
||||
val = status / 2;
|
||||
int val_size = sizeof(val);
|
||||
res = SockSet(fd, SOL_SOCKET, SO_SNDLOWAT, &val, val_size);
|
||||
val = status / 2;
|
||||
int val_size = sizeof(val);
|
||||
res = SockSet(fd, SOL_SOCKET, SO_SNDLOWAT, &val, val_size);
|
||||
}
|
||||
#else
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); // Non-blocking mode
|
||||
@ -3446,7 +3446,8 @@ static void close_conn(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;
|
||||
#else
|
||||
int on = 1;
|
||||
@ -3482,13 +3483,12 @@ void mg_connect_resolved(struct mg_connection *c) {
|
||||
if ((rc = connect(FD(c), &usa.sa, slen)) == 0) {
|
||||
mg_call(c, MG_EV_CONNECT, NULL);
|
||||
} else if (mg_sock_would_block()) {
|
||||
MG_DEBUG(("%lu %p connect in progress...", c->id, c->fd));
|
||||
c->is_connecting = 1;
|
||||
} else {
|
||||
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) {
|
||||
@ -3513,7 +3513,8 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
|
||||
if (MG_SOCK_ERRNO != EAGAIN)
|
||||
#endif
|
||||
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) {
|
||||
MG_ERROR(("%ld > %ld", (long) fd, (long) FD_SETSIZE));
|
||||
closesocket(fd);
|
||||
|
15
src/sock.c
15
src/sock.c
@ -191,9 +191,9 @@ static void mg_set_non_blocking_mode(SOCKET fd) {
|
||||
int status = 0;
|
||||
int res = SockStatus(fd, FDSTATUS_SEND, &status);
|
||||
if (res == 0 && status > 0) {
|
||||
val = status / 2;
|
||||
int val_size = sizeof(val);
|
||||
res = SockSet(fd, SOL_SOCKET, SO_SNDLOWAT, &val, val_size);
|
||||
val = status / 2;
|
||||
int val_size = sizeof(val);
|
||||
res = SockSet(fd, SOL_SOCKET, SO_SNDLOWAT, &val, val_size);
|
||||
}
|
||||
#else
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); // Non-blocking mode
|
||||
@ -312,7 +312,8 @@ static void close_conn(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;
|
||||
#else
|
||||
int on = 1;
|
||||
@ -348,13 +349,12 @@ void mg_connect_resolved(struct mg_connection *c) {
|
||||
if ((rc = connect(FD(c), &usa.sa, slen)) == 0) {
|
||||
mg_call(c, MG_EV_CONNECT, NULL);
|
||||
} else if (mg_sock_would_block()) {
|
||||
MG_DEBUG(("%lu %p connect in progress...", c->id, c->fd));
|
||||
c->is_connecting = 1;
|
||||
} else {
|
||||
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) {
|
||||
@ -379,7 +379,8 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
|
||||
if (MG_SOCK_ERRNO != EAGAIN)
|
||||
#endif
|
||||
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) {
|
||||
MG_ERROR(("%ld > %ld", (long) fd, (long) FD_SETSIZE));
|
||||
closesocket(fd);
|
||||
|
@ -300,6 +300,7 @@ static void test_sntp(void) {
|
||||
ASSERT(c != NULL);
|
||||
ASSERT(c->is_udp == 1);
|
||||
for (i = 0; i < 500 && ms == 0; i++) mg_mgr_poll(&mgr, 10);
|
||||
MG_DEBUG(("ms: %lld", ms));
|
||||
ASSERT(ms > 0);
|
||||
mg_mgr_free(&mgr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user