mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-26 12:14:56 +00:00
Merge pull request #1360 from zudwalex/azure_basics
Add AzureRTOS basic support
This commit is contained in:
7 files changed
+120
-6
No files matched your search
+10
-2
@@ -120,6 +120,8 @@ static void mg_set_non_blocking_mode(SOCKET fd) {
|
||||
setsockopt(fd, 0, FREERTOS_SO_SNDTIMEO, &off, sizeof(off));
|
||||
#elif MG_ARCH == MG_ARCH_FREERTOS_LWIP
|
||||
lwip_fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#elif MG_ARCH == MG_ARCH_AZURERTOS
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#else
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK, FD_CLOEXEC);
|
||||
#endif
|
||||
@@ -165,7 +167,7 @@ SOCKET mg_open_listener(const char *url, struct mg_addr *addr) {
|
||||
#endif
|
||||
bind(fd, &usa.sa, slen) == 0 &&
|
||||
// NOTE(lsm): FreeRTOS uses backlog value as a connection limit
|
||||
(type == SOCK_DGRAM || listen(fd, 128) == 0)) {
|
||||
(type == SOCK_DGRAM || listen(fd, MG_SOCK_LISTEN_BACKLOG_SIZE) == 0)) {
|
||||
// In case port was set to 0, get the real port number
|
||||
if (getsockname(fd, &usa.sa, &slen) == 0) {
|
||||
addr->port = usa.sin.sin_port;
|
||||
@@ -290,7 +292,7 @@ static void close_conn(struct mg_connection *c) {
|
||||
}
|
||||
|
||||
static void setsockopts(struct mg_connection *c) {
|
||||
#if MG_ARCH == MG_ARCH_FREERTOS_TCP
|
||||
#if MG_ARCH == MG_ARCH_FREERTOS_TCP || MG_ARCH == MG_ARCH_AZURERTOS
|
||||
(void) c;
|
||||
#else
|
||||
int on = 1;
|
||||
@@ -364,6 +366,12 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
|
||||
socklen_t sa_len = sizeof(usa);
|
||||
SOCKET fd = accept(FD(lsn), &usa.sa, &sa_len);
|
||||
if (fd == INVALID_SOCKET) {
|
||||
#if MG_ARCH == MG_ARCH_AZURERTOS
|
||||
// AzureRTOS, 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 (MG_SOCK_ERRNO != EAGAIN)
|
||||
#endif
|
||||
LOG(LL_ERROR, ("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO));
|
||||
#if (!defined(_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP))
|
||||
} else if ((long) fd >= FD_SETSIZE) {
|
||||
|
||||
Reference in new issue
Block a user