Skip to content

Commit f888b30

Browse files
committed
TLS corner cases
1 parent 10029d6 commit f888b30

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/sock.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
480480
size_t max = 1;
481481
for (struct mg_connection *c = mgr->conns; c != NULL; c = c->next) {
482482
c->is_readable = c->is_writable = 0;
483-
if (mg_tls_pending(c) > 0) ms = 1, c->is_readable = 1;
483+
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) ms = 1, c->is_readable = 1;
484484
if (can_write(c)) MG_EPOLL_MOD(c, 1);
485485
if (c->is_closing) ms = 1;
486486
max++;
@@ -496,7 +496,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
496496
bool wr = evs[i].events & EPOLLOUT;
497497
c->is_readable = can_read(c) && rd ? 1U : 0;
498498
c->is_writable = can_write(c) && wr ? 1U : 0;
499-
if (mg_tls_pending(c) > 0) c->is_readable = 1;
499+
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) c->is_readable = 1;
500500
}
501501
}
502502
(void) skip_iotest;
@@ -510,7 +510,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
510510
c->is_readable = c->is_writable = 0;
511511
if (skip_iotest(c)) {
512512
// Socket not valid, ignore
513-
} else if (mg_tls_pending(c) > 0) {
513+
} else if (c->rtls.len > 0 || mg_tls_pending(c) > 0) {
514514
ms = 1; // Don't wait if TLS is ready
515515
} else {
516516
fds[n].fd = FD(c);
@@ -532,7 +532,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
532532
for (struct mg_connection *c = mgr->conns; c != NULL; c = c->next) {
533533
if (skip_iotest(c)) {
534534
// Socket not valid, ignore
535-
} else if (mg_tls_pending(c) > 0) {
535+
} else if (c->rtls.len > 0 || mg_tls_pending(c) > 0) {
536536
c->is_readable = 1;
537537
} else {
538538
if (fds[n].revents & POLLERR) {
@@ -541,7 +541,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
541541
c->is_readable =
542542
(unsigned) (fds[n].revents & (POLLIN | POLLHUP) ? 1 : 0);
543543
c->is_writable = (unsigned) (fds[n].revents & POLLOUT ? 1 : 0);
544-
if (mg_tls_pending(c) > 0) c->is_readable = 1;
544+
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) c->is_readable = 1;
545545
}
546546
n++;
547547
}
@@ -563,7 +563,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
563563
FD_SET(FD(c), &eset);
564564
if (can_read(c)) FD_SET(FD(c), &rset);
565565
if (can_write(c)) FD_SET(FD(c), &wset);
566-
if (mg_tls_pending(c) > 0) tvp = &tv_zero;
566+
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) tvp = &tv_zero;
567567
if (FD(c) > maxfd) maxfd = FD(c);
568568
if (c->is_closing) ms = 1;
569569
}
@@ -585,7 +585,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
585585
} else {
586586
c->is_readable = FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &rset);
587587
c->is_writable = FD(c) != MG_INVALID_SOCKET && FD_ISSET(FD(c), &wset);
588-
if (mg_tls_pending(c) > 0) c->is_readable = 1;
588+
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) c->is_readable = 1;
589589
}
590590
}
591591
#endif

0 commit comments

Comments
 (0)