mirror of
https://github.com/cesanta/mongoose.git
synced 2025-08-06 13:37:34 +08:00
Merge pull request #3167 from cesanta/threadx
Some checks failed
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, , mip_test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, , test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, BUILTIN, mip_test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, BUILTIN, test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, , mip_test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, , test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, BUILTIN, mip_test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, BUILTIN, test) (push) Has been cancelled
Build and test - essentials / s390 (push) Has been cancelled
Build and test - essentials / armhf (push) Has been cancelled
Build and test - essentials / unamalgamated-mg_prefix (push) Has been cancelled
Build and test - essentials / macos SSL=${{ matrix.ssl }} () (push) Has been cancelled
Build and test - essentials / macos SSL=${{ matrix.ssl }} (BUILTIN) (push) Has been cancelled
Build and test - essentials / windows ${{ matrix.target }} (mingw++) (push) Has been cancelled
Build and test - essentials / windows ${{ matrix.target }} (vc22) (push) Has been cancelled
Build and test - essentials / windows ${{ matrix.target }} (vc98) (push) Has been cancelled
Build and test - essentials / arm (push) Has been cancelled
Build and test - essentials / riscv (push) Has been cancelled
Build and test - essentials / tutorials (push) Has been cancelled
Build and test - essentials / tutorials_win (push) Has been cancelled
Build and test - essentials / tutorials_mac (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/xmc47_relax-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/xmc72_evk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/xmc_plt2go_4400-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/frdm-mcxn947-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/frdm-mcxn947-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1020-evk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1060-evk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1170-evk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-2-w-picosdk-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-w-picosdk-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f429zi-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f429zi-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h563zi-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h563zi-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h723zg-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h723zg-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h743zi-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h743zi-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/stm32h573i-dk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/stm32h573i-dk-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:ti/ek-tm4c1294xl-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:ti/ek-tm4c1294xl-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:http/http-client/esp8266/http-client-server]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:http/uart-bridge/esp32]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-g031-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:esp32]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:http/device-dashboard/microchip/same54-xpro]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1020-evk-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1060-evk-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1170-evk-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-2-w-picosdk-freertos-lwip]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-rndis-dashboard]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-w-picosdk-freertos-lwip]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:renesas/ek-ra6m4-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-baremetal-builtin-cmsis_driver]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-freertos-tcp]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-rndis-device]) (push) Has been cancelled
Build and test - essentials / cube_examples (push) Has been cancelled
Build and test - essentials / test_f7 (push) Has been cancelled
Build and test - essentials / test_f4 (push) Has been cancelled
Build and test - essentials / test_h743 (push) Has been cancelled
Build and test - essentials / test_h723 (push) Has been cancelled
Build and test - essentials / test_h5 (push) Has been cancelled
Build and test - essentials / test_rt1020 (push) Has been cancelled
Build and test - essentials / test_rt1060 (push) Has been cancelled
Build and test - essentials / test_rt1170 (push) Has been cancelled
Build and test - essentials / test_ra6m4 (push) Has been cancelled
Build and test - essentials / test_tm4c (push) Has been cancelled
Build and test - essentials / test_same54 (push) Has been cancelled
Build and test - essentials / test_pico_w5500 (push) Has been cancelled
Some checks failed
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, , mip_test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, , test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, BUILTIN, mip_test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, BUILTIN, test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, , mip_test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, , test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, BUILTIN, mip_test) (push) Has been cancelled
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, BUILTIN, test) (push) Has been cancelled
Build and test - essentials / s390 (push) Has been cancelled
Build and test - essentials / armhf (push) Has been cancelled
Build and test - essentials / unamalgamated-mg_prefix (push) Has been cancelled
Build and test - essentials / macos SSL=${{ matrix.ssl }} () (push) Has been cancelled
Build and test - essentials / macos SSL=${{ matrix.ssl }} (BUILTIN) (push) Has been cancelled
Build and test - essentials / windows ${{ matrix.target }} (mingw++) (push) Has been cancelled
Build and test - essentials / windows ${{ matrix.target }} (vc22) (push) Has been cancelled
Build and test - essentials / windows ${{ matrix.target }} (vc98) (push) Has been cancelled
Build and test - essentials / arm (push) Has been cancelled
Build and test - essentials / riscv (push) Has been cancelled
Build and test - essentials / tutorials (push) Has been cancelled
Build and test - essentials / tutorials_win (push) Has been cancelled
Build and test - essentials / tutorials_mac (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/xmc47_relax-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/xmc72_evk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/xmc_plt2go_4400-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/frdm-mcxn947-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/frdm-mcxn947-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1020-evk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1060-evk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1170-evk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-2-w-picosdk-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-w-picosdk-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f429zi-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f429zi-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h563zi-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h563zi-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h723zg-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h723zg-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h743zi-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h743zi-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/stm32h573i-dk-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/stm32h573i-dk-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:ti/ek-tm4c1294xl-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:ti/ek-tm4c1294xl-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:http/http-client/esp8266/http-client-server]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:http/uart-bridge/esp32]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-g031-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:esp32]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:http/device-dashboard/microchip/same54-xpro]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1020-evk-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1060-evk-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1170-evk-make-freertos-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-2-w-picosdk-freertos-lwip]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-rndis-dashboard]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-w-picosdk-freertos-lwip]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:renesas/ek-ra6m4-make-baremetal-builtin]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-baremetal-builtin-cmsis_driver]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-freertos-tcp]) (push) Has been cancelled
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-rndis-device]) (push) Has been cancelled
Build and test - essentials / cube_examples (push) Has been cancelled
Build and test - essentials / test_f7 (push) Has been cancelled
Build and test - essentials / test_f4 (push) Has been cancelled
Build and test - essentials / test_h743 (push) Has been cancelled
Build and test - essentials / test_h723 (push) Has been cancelled
Build and test - essentials / test_h5 (push) Has been cancelled
Build and test - essentials / test_rt1020 (push) Has been cancelled
Build and test - essentials / test_rt1060 (push) Has been cancelled
Build and test - essentials / test_rt1170 (push) Has been cancelled
Build and test - essentials / test_ra6m4 (push) Has been cancelled
Build and test - essentials / test_tm4c (push) Has been cancelled
Build and test - essentials / test_same54 (push) Has been cancelled
Build and test - essentials / test_pico_w5500 (push) Has been cancelled
Add MG_ARCH_TREADX
This commit is contained in:
commit
0eb8bf6b51
33
mongoose.c
33
mongoose.c
@ -2028,13 +2028,11 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm,
|
||||
// If a browser sends us "Accept-Encoding: gzip", try to open .gz first
|
||||
struct mg_str *ae = mg_http_get_header(hm, "Accept-Encoding");
|
||||
if (ae != NULL) {
|
||||
char *ae_ = mg_mprintf("%.*s", ae->len, ae->buf);
|
||||
if (ae_ != NULL && strstr(ae_, "gzip") != NULL) {
|
||||
if (mg_match(*ae, mg_str("*gzip*"), NULL)) {
|
||||
mg_snprintf(tmp, sizeof(tmp), "%s.gz", path);
|
||||
fd = mg_fs_open(fs, tmp, MG_FS_READ);
|
||||
if (fd != NULL) gzip = true, path = tmp;
|
||||
}
|
||||
free(ae_);
|
||||
}
|
||||
// No luck opening .gz? Open what we've told to open
|
||||
if (fd == NULL) fd = mg_fs_open(fs, path, MG_FS_READ);
|
||||
@ -2125,7 +2123,7 @@ static void printdirentry(const char *name, void *userdata) {
|
||||
sizeof(path)) {
|
||||
MG_ERROR(("%s truncated", name));
|
||||
} else if ((flags = fs->st(path, &size, &t)) == 0) {
|
||||
MG_ERROR(("%lu stat(%s): %d", d->c->id, path, errno));
|
||||
MG_ERROR(("%lu stat(%s)", d->c->id, path));
|
||||
} else {
|
||||
const char *slash = flags & MG_FS_DIR ? "/" : "";
|
||||
if (flags & MG_FS_DIR) {
|
||||
@ -2416,7 +2414,7 @@ long mg_http_upload(struct mg_connection *c, struct mg_http_message *hm,
|
||||
mg_http_reply(c, 400, "", "%s: offset mismatch", path);
|
||||
res = -5;
|
||||
} else if ((fd = mg_fs_open(fs, path, MG_FS_WRITE)) == NULL) {
|
||||
mg_http_reply(c, 400, "", "open(%s): %d", path, errno);
|
||||
mg_http_reply(c, 400, "", "open(%s)", path);
|
||||
res = -6;
|
||||
} else {
|
||||
res = offset + (long) fs->wr(fd->fd, hm->body.buf, hm->body.len);
|
||||
@ -4064,7 +4062,7 @@ struct mg_connection *mg_listen(struct mg_mgr *mgr, const char *url,
|
||||
if ((c = mg_alloc_conn(mgr)) == NULL) {
|
||||
MG_ERROR(("OOM %s", url));
|
||||
} else if (!mg_open_listener(c, url)) {
|
||||
MG_ERROR(("Failed: %s, errno %d", url, errno));
|
||||
MG_ERROR(("Failed: %s", url));
|
||||
MG_PROF_FREE(c);
|
||||
free(c);
|
||||
c = NULL;
|
||||
@ -8779,8 +8777,10 @@ static void mg_set_non_blocking_mode(MG_SOCKET_TYPE fd) {
|
||||
if (setsockopt(fd, 0, FREERTOS_SO_SNDTIMEO, &off, sizeof(off)) != 0) (void) 0;
|
||||
#elif MG_ENABLE_LWIP
|
||||
lwip_fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#elif MG_ARCH == MG_ARCH_AZURERTOS
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#elif MG_ARCH == MG_ARCH_THREADX
|
||||
// NetxDuo fails to send large blocks of data to the non-blocking sockets
|
||||
(void) fd;
|
||||
//fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#elif MG_ARCH == MG_ARCH_TIRTOS
|
||||
int val = 0;
|
||||
setsockopt(fd, SOL_SOCKET, SO_BLOCKING, &val, sizeof(val));
|
||||
@ -8987,7 +8987,7 @@ static void connect_conn(struct mg_connection *c) {
|
||||
}
|
||||
|
||||
static void setsockopts(struct mg_connection *c) {
|
||||
#if MG_ENABLE_FREERTOS_TCP || MG_ARCH == MG_ARCH_AZURERTOS || \
|
||||
#if MG_ENABLE_FREERTOS_TCP || MG_ARCH == MG_ARCH_THREADX || \
|
||||
MG_ARCH == MG_ARCH_TIRTOS
|
||||
(void) c;
|
||||
#else
|
||||
@ -9059,8 +9059,8 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
|
||||
socklen_t sa_len = sizeof(usa);
|
||||
MG_SOCKET_TYPE fd = raccept(FD(lsn), &usa, &sa_len);
|
||||
if (fd == MG_INVALID_SOCKET) {
|
||||
#if MG_ARCH == MG_ARCH_AZURERTOS || defined(__ECOS)
|
||||
// AzureRTOS, in non-block socket mode can mark listening socket readable
|
||||
#if MG_ARCH == MG_ARCH_THREADX || defined(__ECOS)
|
||||
// NetxDuo, in non-block socket mode can mark listening socket readable
|
||||
// even it is not. See comment for 'select' func implementation in
|
||||
// nx_bsd.c That's not an error, just should try later
|
||||
if (errno != EAGAIN)
|
||||
@ -9221,11 +9221,11 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
if (c->is_closing) tvp = &tv_zero;
|
||||
}
|
||||
|
||||
if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) < 0) {
|
||||
if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) <= 0) {
|
||||
#if MG_ARCH == MG_ARCH_WIN32
|
||||
if (maxfd == 0) Sleep(ms); // On Windows, select fails if no sockets
|
||||
#else
|
||||
MG_ERROR(("select: %d %d", rc, MG_SOCK_ERR(rc)));
|
||||
if (rc < 0) MG_ERROR(("select: %d %d", rc, MG_SOCK_ERR(rc)));
|
||||
#endif
|
||||
FD_ZERO(&rset);
|
||||
FD_ZERO(&wset);
|
||||
@ -9234,7 +9234,12 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
|
||||
for (c = mgr->conns; c != NULL; c = c->next) {
|
||||
if (FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &eset)) {
|
||||
#if MG_ARCH == MG_ARCH_THREADX
|
||||
// NetxDuo stack returns exceptions for listening connection after accept
|
||||
if (c->is_listening == 0) mg_error(c, "socket error");
|
||||
#else
|
||||
mg_error(c, "socket error");
|
||||
#endif
|
||||
} else {
|
||||
c->is_readable = FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &rset);
|
||||
c->is_writable = FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &wset);
|
||||
@ -19850,7 +19855,7 @@ uint64_t mg_millis(void) {
|
||||
#elif MG_ARCH == MG_ARCH_ESP8266 || MG_ARCH == MG_ARCH_ESP32 || \
|
||||
MG_ARCH == MG_ARCH_FREERTOS
|
||||
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
#elif MG_ARCH == MG_ARCH_AZURERTOS
|
||||
#elif MG_ARCH == MG_ARCH_THREADX
|
||||
return tx_time_get() * (1000 /* MS per SEC */ / TX_TIMER_TICKS_PER_SECOND);
|
||||
#elif MG_ARCH == MG_ARCH_TIRTOS
|
||||
return (uint64_t) Clock_getTicks();
|
||||
|
75
mongoose.h
75
mongoose.h
@ -33,7 +33,7 @@ extern "C" {
|
||||
#define MG_ARCH_ESP32 3 // ESP32
|
||||
#define MG_ARCH_ESP8266 4 // ESP8266
|
||||
#define MG_ARCH_FREERTOS 5 // FreeRTOS
|
||||
#define MG_ARCH_AZURERTOS 6 // MS Azure RTOS
|
||||
#define MG_ARCH_THREADX 6 // Eclipse ThreadX (former MS Azure RTOS)
|
||||
#define MG_ARCH_ZEPHYR 7 // Zephyr RTOS
|
||||
#define MG_ARCH_NEWLIB 8 // Bare metal ARM
|
||||
#define MG_ARCH_CMSIS_RTOS1 9 // CMSIS-RTOS API v1 (Keil RTX)
|
||||
@ -57,7 +57,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(MG_ARCH)
|
||||
#error "MG_ARCH is not specified and we couldn't guess it. Define MG_ARCH=... in your compiler"
|
||||
#error "MG_ARCH is not specified and we couldn't guess it. Define MG_ARCH=... in mongoose_config.h"
|
||||
#endif
|
||||
|
||||
// http://esr.ibiblio.org/?p=5095
|
||||
@ -77,6 +77,7 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
|
||||
#if MG_ARCH == MG_ARCH_ARMCGT
|
||||
|
||||
#include <ctype.h>
|
||||
@ -96,33 +97,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if MG_ARCH == MG_ARCH_AZURERTOS
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <fx_api.h>
|
||||
#include <tx_api.h>
|
||||
|
||||
#include <nx_api.h>
|
||||
#include <nx_bsd.h>
|
||||
#include <nx_port.h>
|
||||
#include <tx_port.h>
|
||||
|
||||
#define PATH_MAX FX_MAXIMUM_PATH
|
||||
#define MG_DIRSEP '\\'
|
||||
|
||||
#define socklen_t int
|
||||
#define closesocket(x) soc_close(x)
|
||||
|
||||
#undef FOPEN_MAX
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if MG_ARCH == MG_ARCH_ESP32
|
||||
|
||||
#include <ctype.h>
|
||||
@ -347,6 +321,49 @@ static inline int mg_mkdir(const char *path, mode_t mode) {
|
||||
#endif
|
||||
|
||||
|
||||
#if MG_ARCH == MG_ARCH_THREADX
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
// Do not include time.h and stdlib.h, since they conflict with nxd_bsd.h
|
||||
// extern time_t time(time_t *);
|
||||
#include <nxd_bsd.h>
|
||||
|
||||
#define MG_DIRSEP '\\'
|
||||
#undef FOPEN_MAX
|
||||
|
||||
#ifndef MG_PATH_MAX
|
||||
#define MG_PATH_MAX 32
|
||||
#endif
|
||||
|
||||
#ifndef MG_SOCK_LISTEN_BACKLOG_SIZE
|
||||
#define MG_SOCK_LISTEN_BACKLOG_SIZE 3
|
||||
#endif
|
||||
|
||||
#ifndef MG_ENABLE_IPV6
|
||||
#define MG_ENABLE_IPV6 0
|
||||
#endif
|
||||
|
||||
#define socklen_t int
|
||||
#define closesocket(x) soc_close(x)
|
||||
|
||||
// In order to enable BSD support in NetxDuo, do the following (assuming Cube):
|
||||
// 1. Add nxd_bsd.h and nxd_bsd.c to the repo:
|
||||
// https://github.com/eclipse-threadx/netxduo/blob/v6.1.12_rel/addons/BSD/nxd_bsd.c
|
||||
// https://github.com/eclipse-threadx/netxduo/blob/v6.1.12_rel/addons/BSD/nxd_bsd.h
|
||||
// 2. Add to tx_user.h
|
||||
// #define TX_THREAD_USER_EXTENSION int bsd_errno;
|
||||
// 3. Add to nx_user.h
|
||||
// #define NX_ENABLE_EXTENDED_NOTIFY_SUPPORT
|
||||
// 4. Add __CCRX__ build preprocessor constant
|
||||
// Project -> Properties -> C/C++ -> Settings -> MCU Compiler -> Preprocessor
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if MG_ARCH == MG_ARCH_TIRTOS
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define MG_ARCH_ESP32 3 // ESP32
|
||||
#define MG_ARCH_ESP8266 4 // ESP8266
|
||||
#define MG_ARCH_FREERTOS 5 // FreeRTOS
|
||||
#define MG_ARCH_AZURERTOS 6 // MS Azure RTOS
|
||||
#define MG_ARCH_THREADX 6 // Eclipse ThreadX (former MS Azure RTOS)
|
||||
#define MG_ARCH_ZEPHYR 7 // Zephyr RTOS
|
||||
#define MG_ARCH_NEWLIB 8 // Bare metal ARM
|
||||
#define MG_ARCH_CMSIS_RTOS1 9 // CMSIS-RTOS API v1 (Keil RTX)
|
||||
@ -30,7 +30,7 @@
|
||||
#endif
|
||||
|
||||
#if !defined(MG_ARCH)
|
||||
#error "MG_ARCH is not specified and we couldn't guess it. Define MG_ARCH=... in your compiler"
|
||||
#error "MG_ARCH is not specified and we couldn't guess it. Define MG_ARCH=... in mongoose_config.h"
|
||||
#endif
|
||||
|
||||
// http://esr.ibiblio.org/?p=5095
|
||||
@ -44,6 +44,7 @@
|
||||
#include "arch_unix.h"
|
||||
#include "arch_win32.h"
|
||||
#include "arch_zephyr.h"
|
||||
#include "arch_threadx.h"
|
||||
|
||||
#include "net_ft.h"
|
||||
#include "net_lwip.h"
|
||||
|
@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#if MG_ARCH == MG_ARCH_AZURERTOS
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <fx_api.h>
|
||||
#include <tx_api.h>
|
||||
|
||||
#include <nx_api.h>
|
||||
#include <nx_bsd.h>
|
||||
#include <nx_port.h>
|
||||
#include <tx_port.h>
|
||||
|
||||
#define PATH_MAX FX_MAXIMUM_PATH
|
||||
#define MG_DIRSEP '\\'
|
||||
|
||||
#define socklen_t int
|
||||
#define closesocket(x) soc_close(x)
|
||||
|
||||
#undef FOPEN_MAX
|
||||
|
||||
#endif
|
43
src/arch_threadx.h
Normal file
43
src/arch_threadx.h
Normal file
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#if MG_ARCH == MG_ARCH_THREADX
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
// Do not include time.h and stdlib.h, since they conflict with nxd_bsd.h
|
||||
// extern time_t time(time_t *);
|
||||
#include <nxd_bsd.h>
|
||||
|
||||
#define MG_DIRSEP '\\'
|
||||
#undef FOPEN_MAX
|
||||
|
||||
#ifndef MG_PATH_MAX
|
||||
#define MG_PATH_MAX 32
|
||||
#endif
|
||||
|
||||
#ifndef MG_SOCK_LISTEN_BACKLOG_SIZE
|
||||
#define MG_SOCK_LISTEN_BACKLOG_SIZE 3
|
||||
#endif
|
||||
|
||||
#ifndef MG_ENABLE_IPV6
|
||||
#define MG_ENABLE_IPV6 0
|
||||
#endif
|
||||
|
||||
#define socklen_t int
|
||||
#define closesocket(x) soc_close(x)
|
||||
|
||||
// In order to enable BSD support in NetxDuo, do the following (assuming Cube):
|
||||
// 1. Add nxd_bsd.h and nxd_bsd.c to the repo:
|
||||
// https://github.com/eclipse-threadx/netxduo/blob/v6.1.12_rel/addons/BSD/nxd_bsd.c
|
||||
// https://github.com/eclipse-threadx/netxduo/blob/v6.1.12_rel/addons/BSD/nxd_bsd.h
|
||||
// 2. Add to tx_user.h
|
||||
// #define TX_THREAD_USER_EXTENSION int bsd_errno;
|
||||
// 3. Add to nx_user.h
|
||||
// #define NX_ENABLE_EXTENDED_NOTIFY_SUPPORT
|
||||
// 4. Add __CCRX__ build preprocessor constant
|
||||
// Project -> Properties -> C/C++ -> Settings -> MCU Compiler -> Preprocessor
|
||||
|
||||
#endif
|
@ -589,13 +589,11 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm,
|
||||
// If a browser sends us "Accept-Encoding: gzip", try to open .gz first
|
||||
struct mg_str *ae = mg_http_get_header(hm, "Accept-Encoding");
|
||||
if (ae != NULL) {
|
||||
char *ae_ = mg_mprintf("%.*s", ae->len, ae->buf);
|
||||
if (ae_ != NULL && strstr(ae_, "gzip") != NULL) {
|
||||
if (mg_match(*ae, mg_str("*gzip*"), NULL)) {
|
||||
mg_snprintf(tmp, sizeof(tmp), "%s.gz", path);
|
||||
fd = mg_fs_open(fs, tmp, MG_FS_READ);
|
||||
if (fd != NULL) gzip = true, path = tmp;
|
||||
}
|
||||
free(ae_);
|
||||
}
|
||||
// No luck opening .gz? Open what we've told to open
|
||||
if (fd == NULL) fd = mg_fs_open(fs, path, MG_FS_READ);
|
||||
@ -686,7 +684,7 @@ static void printdirentry(const char *name, void *userdata) {
|
||||
sizeof(path)) {
|
||||
MG_ERROR(("%s truncated", name));
|
||||
} else if ((flags = fs->st(path, &size, &t)) == 0) {
|
||||
MG_ERROR(("%lu stat(%s): %d", d->c->id, path, errno));
|
||||
MG_ERROR(("%lu stat(%s)", d->c->id, path));
|
||||
} else {
|
||||
const char *slash = flags & MG_FS_DIR ? "/" : "";
|
||||
if (flags & MG_FS_DIR) {
|
||||
@ -977,7 +975,7 @@ long mg_http_upload(struct mg_connection *c, struct mg_http_message *hm,
|
||||
mg_http_reply(c, 400, "", "%s: offset mismatch", path);
|
||||
res = -5;
|
||||
} else if ((fd = mg_fs_open(fs, path, MG_FS_WRITE)) == NULL) {
|
||||
mg_http_reply(c, 400, "", "open(%s): %d", path, errno);
|
||||
mg_http_reply(c, 400, "", "open(%s)", path);
|
||||
res = -6;
|
||||
} else {
|
||||
res = offset + (long) fs->wr(fd->fd, hm->body.buf, hm->body.len);
|
||||
|
@ -184,7 +184,7 @@ struct mg_connection *mg_listen(struct mg_mgr *mgr, const char *url,
|
||||
if ((c = mg_alloc_conn(mgr)) == NULL) {
|
||||
MG_ERROR(("OOM %s", url));
|
||||
} else if (!mg_open_listener(c, url)) {
|
||||
MG_ERROR(("Failed: %s, errno %d", url, errno));
|
||||
MG_ERROR(("Failed: %s", url));
|
||||
MG_PROF_FREE(c);
|
||||
free(c);
|
||||
c = NULL;
|
||||
|
@ -103,4 +103,5 @@ struct mg_tcpip_spi {
|
||||
uint8_t (*txn)(void *, uint8_t); // SPI transaction: write 1 byte, read reply
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
21
src/sock.c
21
src/sock.c
@ -160,8 +160,10 @@ static void mg_set_non_blocking_mode(MG_SOCKET_TYPE fd) {
|
||||
if (setsockopt(fd, 0, FREERTOS_SO_SNDTIMEO, &off, sizeof(off)) != 0) (void) 0;
|
||||
#elif MG_ENABLE_LWIP
|
||||
lwip_fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#elif MG_ARCH == MG_ARCH_AZURERTOS
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#elif MG_ARCH == MG_ARCH_THREADX
|
||||
// NetxDuo fails to send large blocks of data to the non-blocking sockets
|
||||
(void) fd;
|
||||
//fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#elif MG_ARCH == MG_ARCH_TIRTOS
|
||||
int val = 0;
|
||||
setsockopt(fd, SOL_SOCKET, SO_BLOCKING, &val, sizeof(val));
|
||||
@ -368,7 +370,7 @@ static void connect_conn(struct mg_connection *c) {
|
||||
}
|
||||
|
||||
static void setsockopts(struct mg_connection *c) {
|
||||
#if MG_ENABLE_FREERTOS_TCP || MG_ARCH == MG_ARCH_AZURERTOS || \
|
||||
#if MG_ENABLE_FREERTOS_TCP || MG_ARCH == MG_ARCH_THREADX || \
|
||||
MG_ARCH == MG_ARCH_TIRTOS
|
||||
(void) c;
|
||||
#else
|
||||
@ -440,8 +442,8 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
|
||||
socklen_t sa_len = sizeof(usa);
|
||||
MG_SOCKET_TYPE fd = raccept(FD(lsn), &usa, &sa_len);
|
||||
if (fd == MG_INVALID_SOCKET) {
|
||||
#if MG_ARCH == MG_ARCH_AZURERTOS || defined(__ECOS)
|
||||
// AzureRTOS, in non-block socket mode can mark listening socket readable
|
||||
#if MG_ARCH == MG_ARCH_THREADX || defined(__ECOS)
|
||||
// NetxDuo, in non-block socket mode can mark listening socket readable
|
||||
// even it is not. See comment for 'select' func implementation in
|
||||
// nx_bsd.c That's not an error, just should try later
|
||||
if (errno != EAGAIN)
|
||||
@ -602,11 +604,11 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
if (c->is_closing) tvp = &tv_zero;
|
||||
}
|
||||
|
||||
if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) < 0) {
|
||||
if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) <= 0) {
|
||||
#if MG_ARCH == MG_ARCH_WIN32
|
||||
if (maxfd == 0) Sleep(ms); // On Windows, select fails if no sockets
|
||||
#else
|
||||
MG_ERROR(("select: %d %d", rc, MG_SOCK_ERR(rc)));
|
||||
if (rc < 0) MG_ERROR(("select: %d %d", rc, MG_SOCK_ERR(rc)));
|
||||
#endif
|
||||
FD_ZERO(&rset);
|
||||
FD_ZERO(&wset);
|
||||
@ -615,7 +617,12 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
|
||||
|
||||
for (c = mgr->conns; c != NULL; c = c->next) {
|
||||
if (FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &eset)) {
|
||||
#if MG_ARCH == MG_ARCH_THREADX
|
||||
// NetxDuo stack returns exceptions for listening connection after accept
|
||||
if (c->is_listening == 0) mg_error(c, "socket error");
|
||||
#else
|
||||
mg_error(c, "socket error");
|
||||
#endif
|
||||
} else {
|
||||
c->is_readable = FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &rset);
|
||||
c->is_writable = FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &wset);
|
||||
|
@ -147,7 +147,7 @@ uint64_t mg_millis(void) {
|
||||
#elif MG_ARCH == MG_ARCH_ESP8266 || MG_ARCH == MG_ARCH_ESP32 || \
|
||||
MG_ARCH == MG_ARCH_FREERTOS
|
||||
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
#elif MG_ARCH == MG_ARCH_AZURERTOS
|
||||
#elif MG_ARCH == MG_ARCH_THREADX
|
||||
return tx_time_get() * (1000 /* MS per SEC */ / TX_TIMER_TICKS_PER_SECOND);
|
||||
#elif MG_ARCH == MG_ARCH_TIRTOS
|
||||
return (uint64_t) Clock_getTicks();
|
||||
|
@ -47,9 +47,7 @@ int main(int argc, char *argv[]) {
|
||||
int i, j, ch;
|
||||
const char *strip_prefix = "";
|
||||
|
||||
printf("%s", "#include <stddef.h>\n");
|
||||
printf("%s", "#include <string.h>\n");
|
||||
printf("%s", "#include <time.h>\n");
|
||||
printf("%s", "#include \"mongoose.h\"\n");
|
||||
printf("%s", "\n");
|
||||
printf("%s", "#if defined(__cplusplus)\nextern \"C\" {\n#endif\n");
|
||||
printf("%s", "const char *mg_unlist(size_t no);\n");
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
const Pack = async function(files) {
|
||||
let out = `// DO NOT EDIT. This file is generated
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "mongoose.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
|
Loading…
Reference in New Issue
Block a user