Merge pull request #2134 from cesanta/freertos-tcp

Fix FreeRTOS-Plus-TCP
This commit is contained in:
Sergio R. Caprile 2023-03-24 16:42:59 -03:00 committed by GitHub
commit 2b8586d1b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 26 deletions

View File

@ -4598,8 +4598,9 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
EventBits_t bits = FreeRTOS_FD_ISSET(c->fd, mgr->ss);
c->is_readable = bits & (eSELECT_READ | eSELECT_EXCEPT) ? 1U : 0;
c->is_writable = bits & eSELECT_WRITE ? 1U : 0;
FreeRTOS_FD_CLR(c->fd, mgr->ss,
eSELECT_READ | eSELECT_EXCEPT | eSELECT_WRITE);
if (c->fd != MG_INVALID_SOCKET)
FreeRTOS_FD_CLR(c->fd, mgr->ss,
eSELECT_READ | eSELECT_EXCEPT | eSELECT_WRITE);
}
#elif MG_ENABLE_EPOLL
size_t max = 1;

View File

@ -537,17 +537,20 @@ int sscanf(const char *, const char *, ...);
#define SO_ERROR 0
#define SOL_SOCKET 0
#define SO_REUSEADDR 0
#undef EINTR
#undef EWOULDBLOCK
#undef EINPROGRESS
#undef EPIPE
#undef ECONNRESET
#define EINTR pdFREERTOS_ERRNO_EINTR
#define EWOULDBLOCK pdFREERTOS_ERRNO_EWOULDBLOCK
#define EINPROGRESS pdFREERTOS_ERRNO_EINPROGRESS
#define EPIPE 0
#define ECONNRESET 0
#define EINTR pdFREERTOS_ERRNO_EINTR
#define MG_SOCK_ERR(errcode) ((errcode) < 0 ? (errcode) : 0)
#define MG_SOCK_PENDING(errcode) \
((errcode) == -pdFREERTOS_ERRNO_EWOULDBLOCK || \
(errcode) == -pdFREERTOS_ERRNO_EISCONN || \
(errcode) == -pdFREERTOS_ERRNO_EINPROGRESS || \
(errcode) == -pdFREERTOS_ERRNO_EAGAIN)
#define MG_SOCK_RESET(errcode) ((errcode) == -pdFREERTOS_ERRNO_ENOTCONN)
// actually only if optional timeout is enabled
#define MG_SOCK_INTR(fd) (fd == NULL)
#define sockaddr_in freertos_sockaddr
#define sockaddr freertos_sockaddr
#define accept(a, b, c) FreeRTOS_accept((a), (b), (c))

View File

@ -23,17 +23,20 @@
#define SO_ERROR 0
#define SOL_SOCKET 0
#define SO_REUSEADDR 0
#undef EINTR
#undef EWOULDBLOCK
#undef EINPROGRESS
#undef EPIPE
#undef ECONNRESET
#define EINTR pdFREERTOS_ERRNO_EINTR
#define EWOULDBLOCK pdFREERTOS_ERRNO_EWOULDBLOCK
#define EINPROGRESS pdFREERTOS_ERRNO_EINPROGRESS
#define EPIPE 0
#define ECONNRESET 0
#define EINTR pdFREERTOS_ERRNO_EINTR
#define MG_SOCK_ERR(errcode) ((errcode) < 0 ? (errcode) : 0)
#define MG_SOCK_PENDING(errcode) \
((errcode) == -pdFREERTOS_ERRNO_EWOULDBLOCK || \
(errcode) == -pdFREERTOS_ERRNO_EISCONN || \
(errcode) == -pdFREERTOS_ERRNO_EINPROGRESS || \
(errcode) == -pdFREERTOS_ERRNO_EAGAIN)
#define MG_SOCK_RESET(errcode) ((errcode) == -pdFREERTOS_ERRNO_ENOTCONN)
// actually only if optional timeout is enabled
#define MG_SOCK_INTR(fd) (fd == NULL)
#define sockaddr_in freertos_sockaddr
#define sockaddr freertos_sockaddr
#define accept(a, b, c) FreeRTOS_accept((a), (b), (c))

View File

@ -499,8 +499,9 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
EventBits_t bits = FreeRTOS_FD_ISSET(c->fd, mgr->ss);
c->is_readable = bits & (eSELECT_READ | eSELECT_EXCEPT) ? 1U : 0;
c->is_writable = bits & eSELECT_WRITE ? 1U : 0;
FreeRTOS_FD_CLR(c->fd, mgr->ss,
eSELECT_READ | eSELECT_EXCEPT | eSELECT_WRITE);
if (c->fd != MG_INVALID_SOCKET)
FreeRTOS_FD_CLR(c->fd, mgr->ss,
eSELECT_READ | eSELECT_EXCEPT | eSELECT_WRITE);
}
#elif MG_ENABLE_EPOLL
size_t max = 1;