More SNtp debug 8

This commit is contained in:
Sergey Lyubka
2022-05-27 22:18:14 +01:00
parent 53bca4efab
commit 34c5f63c00
6 changed files with 6 additions and 33 deletions
+1 -19
View File
@@ -1,24 +1,6 @@
name: build
on: [push, pull_request]
jobs:
linux-capture:
runs-on: ubuntu-latest
name: linux capture
steps:
- uses: actions/checkout@v3
- name: Start tcpdump
run: |
sudo tcpdump -nn -i any port 123 or port 53 -w sntp.cap &
sleep 1
- name: test
run: make clean test IPV6=0 SSL= OPTS= V=4 TFLAGS=-DMG_ENABLE_POLL=1
- name: Upload capture
if: always()
run: |
sleep 1
sudo kill -2 $(pgrep tcpdump)
sleep 1
sudo curl -F "file=@sntp.cap" https://file.io/?expires=1w
linux:
runs-on: ubuntu-latest
strategy:
@@ -55,7 +37,7 @@ jobs:
- name: Install packages
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install jq mbedtls openssl
- name: make
run: make test++ upload-coverage IPV6=0 ASAN_OPTIONS=
run: make test++ upload-coverage IPV6=0 ASAN_OPTIONS= TFLAGS=-DMG_ENABLE_POLL=1
- name: openssl
run: make test SSL=OPENSSL IPV6=0 ASAN_OPTIONS= OPENSSL=`echo /usr/local/Cellar/openssl*/*`
- name: exports
+1 -1
View File
@@ -55,7 +55,7 @@ mg_prefix: mongoose.c mongoose.h
# C++ build
test++: CC = g++
test++: C_WARN = -std=c++2a -Wno-shadow -Wno-missing-field-initializers -Wno-deprecated
test++: C_WARN = -std=c++2a -Wno-vla -Wno-shadow -Wno-missing-field-initializers -Wno-deprecated
test++: test
musl: test
+1 -6
View File
@@ -3875,7 +3875,6 @@ int64_t mg_sntp_parse(const unsigned char *buf, size_t len) {
} else {
MG_ERROR(("unexpected version: %d", version));
}
if (res == -1) mg_hexdump(buf, len);
return res;
}
@@ -4415,9 +4414,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
}
}
int res = poll(fds, n, ms);
MG_DEBUG(("n=%d ms=%d res=%d errno=%d", n, ms, res, errno));
if (res < 0) {
if (poll(fds, n, ms) < 0) {
MG_ERROR(("poll failed, errno: %d", MG_SOCK_ERRNO));
} else {
n = 0;
@@ -4428,8 +4425,6 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
c->is_readable = (unsigned) (fds[n].revents & POLLIN ? 1 : 0);
c->is_writable = (unsigned) (fds[n].revents & POLLOUT ? 1 : 0);
if (mg_tls_pending(c) > 0) c->is_readable = 1;
MG_DEBUG((" fd=%d events=%d revents=%d", fds[n].fd, fds[n].events,
fds[n].revents));
fds[n].revents = 0;
n++;
}
-1
View File
@@ -25,7 +25,6 @@ int64_t mg_sntp_parse(const unsigned char *buf, size_t len) {
} else {
MG_ERROR(("unexpected version: %d", version));
}
if (res == -1) mg_hexdump(buf, len);
return res;
}
+1 -5
View File
@@ -496,9 +496,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
}
}
int res = poll(fds, n, ms);
MG_DEBUG(("n=%d ms=%d res=%d errno=%d", n, ms, res, errno));
if (res < 0) {
if (poll(fds, n, ms) < 0) {
MG_ERROR(("poll failed, errno: %d", MG_SOCK_ERRNO));
} else {
n = 0;
@@ -509,8 +507,6 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
c->is_readable = (unsigned) (fds[n].revents & POLLIN ? 1 : 0);
c->is_writable = (unsigned) (fds[n].revents & POLLOUT ? 1 : 0);
if (mg_tls_pending(c) > 0) c->is_readable = 1;
MG_DEBUG((" fd=%d events=%d revents=%d", fds[n].fd, fds[n].events,
fds[n].revents));
fds[n].revents = 0;
n++;
}
+2 -1
View File
@@ -296,12 +296,13 @@ static void test_sntp_server(const char *url) {
int64_t ms = 0;
struct mg_mgr mgr;
struct mg_connection *c = NULL;
int i;
mg_mgr_init(&mgr);
c = mg_sntp_connect(&mgr, url, sntp_cb, &ms);
ASSERT(c != NULL);
ASSERT(c->is_udp == 1);
for (int i = 0; i < 60 && ms == 0; i++) mg_mgr_poll(&mgr, 50);
for (i = 0; i < 60 && ms == 0; i++) mg_mgr_poll(&mgr, 50);
MG_DEBUG(("server: %s, ms: %lld", url ? url : "(default)", ms));
ASSERT(ms > 0);
mg_mgr_free(&mgr);