Add MG_ARCH_RTX

This commit is contained in:
Sergey Lyubka committed 2022-05-12 08:07:51 +01:00
1 parent 86cd567968
commit 31ce219544
6 files changed
+73 -60

No files matched your search

+5 -2
View File
@@ -11,6 +11,7 @@
#define MG_ARCH_RTX_LWIP 8
#define MG_ARCH_ZEPHYR 9
#define MG_ARCH_NEWLIB 10
#define MG_ARCH_RTX 11
#if !defined(MG_ARCH)
#if defined(__unix__) || defined(__APPLE__)
@@ -30,7 +31,7 @@
#endif
#if !defined(MG_ARCH)
#error "MG_ARCH is not specified and we couldn't guess it."
#error "MG_ARCH is not specified and we couldn't guess it. Set -D MG_ARCH=..."
#endif
#endif // !defined(MG_ARCH)
@@ -41,7 +42,7 @@
#endif
#if MG_ARCH == MG_ARCH_CUSTOM
#include "mongoose_custom.h"
#include <mongoose_custom.h>
#endif
#include "arch_esp32.h"
@@ -49,6 +50,8 @@
#include "arch_freertos_lwip.h"
#include "arch_freertos_tcp.h"
#include "arch_newlib.h"
#include "arch_rtx.h"
#include "arch_rtx_lwip.h"
#include "arch_unix.h"
#include "arch_win32.h"
#include "arch_zephyr.h"
+9 -24
View File
@@ -166,7 +166,12 @@ bool mg_send(struct mg_connection *c, const void *buf, size_t len) {
}
static void mg_set_non_blocking_mode(SOCKET fd) {
#if MG_ARCH == MG_ARCH_WIN32 && MG_ENABLE_WINSOCK
#if defined(MG_CUSTOM_NONBLOCK)
MG_CUSTOM_NONBLOCK(fd);
#elif MG_ARCH == MG_ARCH_WIN32 && MG_ENABLE_WINSOCK
unsigned long on = 1;
ioctlsocket(fd, FIONBIO, &on);
#elif MG_ARCH == MG_ARCH_RTX
unsigned long on = 1;
ioctlsocket(fd, FIONBIO, &on);
#elif MG_ARCH == MG_ARCH_FREERTOS_TCP
@@ -199,8 +204,8 @@ bool mg_open_listener(struct mg_connection *c, const char *url) {
if ((fd = socket(af, type, proto)) == INVALID_SOCKET) {
MG_ERROR(("socket: %d", MG_SOCK_ERRNO));
#if (MG_ARCH != MG_ARCH_WIN32 || !defined(SO_EXCLUSIVEADDRUSE)) && \
(!defined(LWIP_SOCKET) || (defined(LWIP_SOCKET) && SO_REUSE == 1))
#if ((MG_ARCH == MG_ARCH_WIN32) || (MG_ARCH == MG_ARCH_UNIX) || \
(defined(LWIP_SOCKET) && SO_REUSE == 1))
} else if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on,
sizeof(on)) != 0) {
// 1. SO_RESUSEADDR is not enabled on Windows because the semantics of
@@ -303,29 +308,9 @@ static void setsockopts(struct mg_connection *c) {
#endif
if (setsockopt(FD(c), SOL_TCP, TCP_NODELAY, (char *) &on, sizeof(on)) != 0)
(void) 0;
#if defined(TCP_QUICKACK)
if (setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on)) != 0)
(void) 0;
#endif
if (setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on)) !=
0)
(void) 0;
#if (defined(ESP32) && ESP32) || (defined(ESP8266) && ESP8266) || \
defined(__linux__)
int idle = 60;
if (setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)) != 0)
(void) 0;
#endif
#if MG_ARCH != MG_ARCH_WIN32 && !defined(__QNX__) && MG_ARCH != MG_ARCH_ZEPHYR
{
int cnt = 3, intvl = 20;
if (setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt)) != 0)
(void) 0;
if (setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl)) !=
0)
(void) 0;
}
#endif
#endif
}
@@ -510,7 +495,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
static void connect_conn(struct mg_connection *c) {
int rc = 0;
#if MG_ARCH != MG_ARCH_FREERTOS_TCP
#if (MG_ARCH != MG_ARCH_FREERTOS_TCP) && (MG_ARCH != MG_ARCH_RTX)
socklen_t len = sizeof(rc);
if (getsockopt(FD(c), SOL_SOCKET, SO_ERROR, (char *) &rc, &len)) rc = 1;
#endif