Selecting fd should be less than `FD_SETSIZE`; close #4966

parent 72928f20
...@@ -1155,6 +1155,7 @@ mrb_io_s_select(mrb_state *mrb, mrb_value klass) ...@@ -1155,6 +1155,7 @@ mrb_io_s_select(mrb_state *mrb, mrb_value klass)
for (i = 0; i < RARRAY_LEN(read); i++) { for (i = 0; i < RARRAY_LEN(read); i++) {
read_io = RARRAY_PTR(read)[i]; read_io = RARRAY_PTR(read)[i];
fptr = io_get_open_fptr(mrb, read_io); fptr = io_get_open_fptr(mrb, read_io);
if (fptr->fd >= FD_SETSIZE) continue;
FD_SET(fptr->fd, rp); FD_SET(fptr->fd, rp);
if (mrb_io_read_data_pending(mrb, read_io)) { if (mrb_io_read_data_pending(mrb, read_io)) {
pending++; pending++;
...@@ -1177,6 +1178,7 @@ mrb_io_s_select(mrb_state *mrb, mrb_value klass) ...@@ -1177,6 +1178,7 @@ mrb_io_s_select(mrb_state *mrb, mrb_value klass)
FD_ZERO(wp); FD_ZERO(wp);
for (i = 0; i < RARRAY_LEN(write); i++) { for (i = 0; i < RARRAY_LEN(write); i++) {
fptr = io_get_open_fptr(mrb, RARRAY_PTR(write)[i]); fptr = io_get_open_fptr(mrb, RARRAY_PTR(write)[i]);
if (fptr->fd >= FD_SETSIZE) continue;
FD_SET(fptr->fd, wp); FD_SET(fptr->fd, wp);
if (max < fptr->fd) if (max < fptr->fd)
max = fptr->fd; max = fptr->fd;
...@@ -1196,6 +1198,7 @@ mrb_io_s_select(mrb_state *mrb, mrb_value klass) ...@@ -1196,6 +1198,7 @@ mrb_io_s_select(mrb_state *mrb, mrb_value klass)
FD_ZERO(ep); FD_ZERO(ep);
for (i = 0; i < RARRAY_LEN(except); i++) { for (i = 0; i < RARRAY_LEN(except); i++) {
fptr = io_get_open_fptr(mrb, RARRAY_PTR(except)[i]); fptr = io_get_open_fptr(mrb, RARRAY_PTR(except)[i]);
if (fptr->fd >= FD_SETSIZE) continue;
FD_SET(fptr->fd, ep); FD_SET(fptr->fd, ep);
if (max < fptr->fd) if (max < fptr->fd)
max = fptr->fd; max = fptr->fd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment