Skip to content

Commit bf059ad

Browse files
authored
Merge pull request cesanta#3197 from cesanta/select
select() minimum wait is now 1ms
2 parents d840b4a + 85df6a6 commit bf059ad

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

mongoose.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9224,7 +9224,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
92249224
}
92259225
}
92269226
#else
9227-
struct timeval tv = {ms / 1000, (ms % 1000) * 1000}, tv_zero = {0, 0}, *tvp;
9227+
struct timeval tv = {ms / 1000, (ms % 1000) * 1000}, tv_1ms = {0, 1000}, *tvp;
92289228
struct mg_connection *c;
92299229
fd_set rset, wset, eset;
92309230
MG_SOCKET_TYPE maxfd = 0;
@@ -9240,9 +9240,9 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
92409240
FD_SET(FD(c), &eset);
92419241
if (can_read(c)) FD_SET(FD(c), &rset);
92429242
if (can_write(c)) FD_SET(FD(c), &wset);
9243-
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) tvp = &tv_zero;
9243+
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) tvp = &tv_1ms;
92449244
if (FD(c) > maxfd) maxfd = FD(c);
9245-
if (c->is_closing) tvp = &tv_zero;
9245+
if (c->is_closing) tvp = &tv_1ms;
92469246
}
92479247

92489248
if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) <= 0) {

src/sock.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
587587
}
588588
}
589589
#else
590-
struct timeval tv = {ms / 1000, (ms % 1000) * 1000}, tv_zero = {0, 0}, *tvp;
590+
struct timeval tv = {ms / 1000, (ms % 1000) * 1000}, tv_1ms = {0, 1000}, *tvp;
591591
struct mg_connection *c;
592592
fd_set rset, wset, eset;
593593
MG_SOCKET_TYPE maxfd = 0;
@@ -603,9 +603,9 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) {
603603
FD_SET(FD(c), &eset);
604604
if (can_read(c)) FD_SET(FD(c), &rset);
605605
if (can_write(c)) FD_SET(FD(c), &wset);
606-
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) tvp = &tv_zero;
606+
if (c->rtls.len > 0 || mg_tls_pending(c) > 0) tvp = &tv_1ms;
607607
if (FD(c) > maxfd) maxfd = FD(c);
608-
if (c->is_closing) tvp = &tv_zero;
608+
if (c->is_closing) tvp = &tv_1ms;
609609
}
610610

611611
if ((rc = select((int) maxfd + 1, &rset, &wset, &eset, tvp)) <= 0) {

0 commit comments

Comments
 (0)