aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-02 05:44:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-02 05:44:13 +0000
commit9486334c722d4a9bf0b71835f56d645f4f178882 (patch)
treeb756ea20bed36980b23dd1e978ab7f4ccd63efb6 /io.c
parent0456bcbf44a3d9b845693f2c5d30dad437897038 (diff)
downloadruby-9486334c722d4a9bf0b71835f56d645f4f178882.tar.gz
io.c: hoisted out io_fd_check_closed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/io.c b/io.c
index a1158a2b86..abbedfd45b 100644
--- a/io.c
+++ b/io.c
@@ -610,6 +610,14 @@ is_socket(int fd, VALUE path)
static const char closed_stream[] = "closed stream";
+static void
+io_fd_check_closed(int fd)
+{
+ if (fd < 0) {
+ rb_raise(rb_eIOError, closed_stream);
+ }
+}
+
void
rb_eof_error(void)
{
@@ -635,9 +643,7 @@ void
rb_io_check_closed(rb_io_t *fptr)
{
rb_io_check_initialized(fptr);
- if (fptr->fd < 0) {
- rb_raise(rb_eIOError, closed_stream);
- }
+ io_fd_check_closed(fptr->fd);
}
static rb_io_t *
@@ -1099,9 +1105,7 @@ io_fflush(rb_io_t *fptr)
int
rb_io_wait_readable(int f)
{
- if (f < 0) {
- rb_raise(rb_eIOError, closed_stream);
- }
+ io_fd_check_closed(f);
switch (errno) {
case EINTR:
#if defined(ERESTART)
@@ -1125,9 +1129,7 @@ rb_io_wait_readable(int f)
int
rb_io_wait_writable(int f)
{
- if (f < 0) {
- rb_raise(rb_eIOError, closed_stream);
- }
+ io_fd_check_closed(f);
switch (errno) {
case EINTR:
#if defined(ERESTART)