Merge pull request #2451 from cesanta/fastclose

Allow fast close
This commit is contained in:
Sergio R. Caprile authored and GitHub committed 2023-11-02 18:52:11 -03:00
commit e418da4bd8
2 files changed
+8

No files matched your search

+4
View File
@@ -6823,6 +6823,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
if (can_read(c)) if (can_read(c))
FreeRTOS_FD_SET(c->fd, mgr->ss, eSELECT_READ | eSELECT_EXCEPT); FreeRTOS_FD_SET(c->fd, mgr->ss, eSELECT_READ | eSELECT_EXCEPT);
if (can_write(c)) FreeRTOS_FD_SET(c->fd, mgr->ss, eSELECT_WRITE); if (can_write(c)) FreeRTOS_FD_SET(c->fd, mgr->ss, eSELECT_WRITE);
if (c->is_closing) ms = 1;
} }
FreeRTOS_select(mgr->ss, pdMS_TO_TICKS(ms)); FreeRTOS_select(mgr->ss, pdMS_TO_TICKS(ms));
for (c = mgr->conns; c != NULL; c = c->next) { for (c = mgr->conns; c != NULL; c = c->next) {
@@ -6839,6 +6840,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
c->is_readable = c->is_writable = 0; c->is_readable = c->is_writable = 0;
if (mg_tls_pending(c) > 0) ms = 1, c->is_readable = 1; if (mg_tls_pending(c) > 0) ms = 1, c->is_readable = 1;
if (can_write(c)) MG_EPOLL_MOD(c, 1); if (can_write(c)) MG_EPOLL_MOD(c, 1);
if (c->is_closing) ms = 1;
max++; max++;
} }
struct epoll_event *evs = (struct epoll_event *) alloca(max * sizeof(evs[0])); struct epoll_event *evs = (struct epoll_event *) alloca(max * sizeof(evs[0]));
@@ -6871,6 +6873,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
fds[n].fd = FD(c); fds[n].fd = FD(c);
if (can_read(c)) fds[n].events |= POLLIN; if (can_read(c)) fds[n].events |= POLLIN;
if (can_write(c)) fds[n].events |= POLLOUT; if (can_write(c)) fds[n].events |= POLLOUT;
if (c->is_closing) ms = 1;
n++; n++;
} }
} }
@@ -6918,6 +6921,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
if (can_write(c)) FD_SET(FD(c), &wset); if (can_write(c)) FD_SET(FD(c), &wset);
if (mg_tls_pending(c) > 0) tvp = &tv_zero; if (mg_tls_pending(c) > 0) tvp = &tv_zero;
if (FD(c) > maxfd) maxfd = FD(c); if (FD(c) > maxfd) maxfd = FD(c);
if (c->is_closing) ms = 1;
} }
if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) < 0) { if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) < 0) {
+4
View File
@@ -442,6 +442,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
if (can_read(c)) if (can_read(c))
FreeRTOS_FD_SET(c->fd, mgr->ss, eSELECT_READ | eSELECT_EXCEPT); FreeRTOS_FD_SET(c->fd, mgr->ss, eSELECT_READ | eSELECT_EXCEPT);
if (can_write(c)) FreeRTOS_FD_SET(c->fd, mgr->ss, eSELECT_WRITE); if (can_write(c)) FreeRTOS_FD_SET(c->fd, mgr->ss, eSELECT_WRITE);
if (c->is_closing) ms = 1;
} }
FreeRTOS_select(mgr->ss, pdMS_TO_TICKS(ms)); FreeRTOS_select(mgr->ss, pdMS_TO_TICKS(ms));
for (c = mgr->conns; c != NULL; c = c->next) { for (c = mgr->conns; c != NULL; c = c->next) {
@@ -458,6 +459,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
c->is_readable = c->is_writable = 0; c->is_readable = c->is_writable = 0;
if (mg_tls_pending(c) > 0) ms = 1, c->is_readable = 1; if (mg_tls_pending(c) > 0) ms = 1, c->is_readable = 1;
if (can_write(c)) MG_EPOLL_MOD(c, 1); if (can_write(c)) MG_EPOLL_MOD(c, 1);
if (c->is_closing) ms = 1;
max++; max++;
} }
struct epoll_event *evs = (struct epoll_event *) alloca(max * sizeof(evs[0])); struct epoll_event *evs = (struct epoll_event *) alloca(max * sizeof(evs[0]));
@@ -490,6 +492,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
fds[n].fd = FD(c); fds[n].fd = FD(c);
if (can_read(c)) fds[n].events |= POLLIN; if (can_read(c)) fds[n].events |= POLLIN;
if (can_write(c)) fds[n].events |= POLLOUT; if (can_write(c)) fds[n].events |= POLLOUT;
if (c->is_closing) ms = 1;
n++; n++;
} }
} }
@@ -537,6 +540,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
if (can_write(c)) FD_SET(FD(c), &wset); if (can_write(c)) FD_SET(FD(c), &wset);
if (mg_tls_pending(c) > 0) tvp = &tv_zero; if (mg_tls_pending(c) > 0) tvp = &tv_zero;
if (FD(c) > maxfd) maxfd = FD(c); if (FD(c) > maxfd) maxfd = FD(c);
if (c->is_closing) ms = 1;
} }
if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) < 0) { if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) < 0) {