File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 6
6
else
7
7
target = "io/wait"
8
8
have_func ( "rb_io_wait" )
9
+ have_func ( "rb_io_descriptor" )
9
10
unless macro_defined? ( "DOSISH" , "#include <ruby.h>" )
10
11
have_header ( ioctl_h = "sys/ioctl.h" ) or ioctl_h = nil
11
12
fionread = %w[ sys/ioctl.h sys/filio.h sys/socket.h ] . find do |h |
Original file line number Diff line number Diff line change @@ -87,8 +87,15 @@ io_nread(VALUE io)
87
87
rb_io_check_readable (fptr );
88
88
len = rb_io_read_pending (fptr );
89
89
if (len > 0 ) return INT2FIX (len );
90
- if (!FIONREAD_POSSIBLE_P (fptr -> fd )) return INT2FIX (0 );
91
- if (ioctl (fptr -> fd , FIONREAD , & n )) return INT2FIX (0 );
90
+
91
+ #ifdef HAVE_RB_IO_DESCRIPTOR
92
+ int fd = rb_io_descriptor (io );
93
+ #else
94
+ int fd = fptr -> fd ;
95
+ #endif
96
+
97
+ if (!FIONREAD_POSSIBLE_P (fd )) return INT2FIX (0 );
98
+ if (ioctl (fd , FIONREAD , & n )) return INT2FIX (0 );
92
99
if (n > 0 ) return ioctl_arg2num (n );
93
100
return INT2FIX (0 );
94
101
}
You can’t perform that action at this time.
0 commit comments