aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-01 03:04:03 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-01 03:04:03 +0000
commitc16f98ab0a4976998d7ff35ffbbb4f3ca110439b (patch)
treec6ee1f7f1f70bff58c09d2842326b39ec64b6bdb /io.c
parent632f448827347626d0c8d1ceef234b00984ce7a4 (diff)
downloadruby-c16f98ab0a4976998d7ff35ffbbb4f3ca110439b.tar.gz
* io.c (rb_maygvl_fd_fix_cloexec): renamed from fd_set_cloexec.
* internal.h (rb_maygvl_fd_fix_cloexec): declared. * ext/socket/init.c (cloexec_accept): use rb_maygvl_fd_fix_cloexec. (rsock_s_accept_nonblock): use rb_update_max_fd. (rsock_s_accept): use rb_update_max_fd. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/io.c b/io.c
index 80e6c28ce1..7ea40b320a 100644
--- a/io.c
+++ b/io.c
@@ -157,15 +157,15 @@ rb_update_max_fd(int fd)
if (max_file_descriptor < fd) max_file_descriptor = fd;
}
-static void
-fd_set_cloexec(int fd)
+void
+rb_maygvl_fd_fix_cloexec(int fd)
{
/* MinGW don't have F_GETFD and FD_CLOEXEC. [ruby-core:40281] */
#ifdef F_GETFD
int flags, flags2, ret;
flags = fcntl(fd, F_GETFD); /* should not fail except EBADF. */
if (flags == -1) {
- rb_bug("fd_set_cloexec: fcntl(%d, F_GETFD) failed: %s", fd, strerror(errno));
+ rb_bug("rb_maygvl_fd_fix_cloexec: fcntl(%d, F_GETFD) failed: %s", fd, strerror(errno));
}
if (fd <= 2)
flags2 = flags & ~FD_CLOEXEC; /* Clear CLOEXEC for standard file descriptors: 0, 1, 2. */
@@ -174,7 +174,7 @@ fd_set_cloexec(int fd)
if (flags != flags2) {
ret = fcntl(fd, F_SETFD, flags2);
if (ret == -1) {
- rb_bug("fd_set_cloexec: fcntl(%d, F_SETFD, %d) failed: %s", fd, flags2, strerror(errno));
+ rb_bug("rb_maygvl_fd_fix_cloexec: fcntl(%d, F_SETFD, %d) failed: %s", fd, flags2, strerror(errno));
}
}
#endif
@@ -183,7 +183,7 @@ fd_set_cloexec(int fd)
void
rb_fd_fix_cloexec(int fd)
{
- fd_set_cloexec(fd);
+ rb_maygvl_fd_fix_cloexec(fd);
if (max_file_descriptor < fd) max_file_descriptor = fd;
}
@@ -198,7 +198,7 @@ rb_cloexec_open(const char *pathname, int flags, mode_t mode)
#endif
ret = open(pathname, flags, mode);
if (ret == -1) return -1;
- fd_set_cloexec(ret);
+ rb_maygvl_fd_fix_cloexec(ret);
return ret;
}
@@ -240,7 +240,7 @@ rb_cloexec_dup2(int oldfd, int newfd)
#endif
if (ret == -1) return -1;
}
- fd_set_cloexec(ret);
+ rb_maygvl_fd_fix_cloexec(ret);
return ret;
}
@@ -282,8 +282,8 @@ rb_cloexec_pipe(int fildes[2])
return -1;
}
#endif
- fd_set_cloexec(fildes[0]);
- fd_set_cloexec(fildes[1]);
+ rb_maygvl_fd_fix_cloexec(fildes[0]);
+ rb_maygvl_fd_fix_cloexec(fildes[1]);
return ret;
}
@@ -298,7 +298,7 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
ret = fcntl(fd, F_DUPFD_CLOEXEC, minfd);
if (ret != -1) {
if (ret <= 2)
- fd_set_cloexec(ret);
+ rb_maygvl_fd_fix_cloexec(ret);
return ret;
}
/* F_DUPFD_CLOEXEC is available since Linux 2.6.24. Linux 2.6.18 fails with EINVAL */
@@ -314,7 +314,7 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
ret = fcntl(fd, F_DUPFD, minfd);
#endif
if (ret == -1) return -1;
- fd_set_cloexec(ret);
+ rb_maygvl_fd_fix_cloexec(ret);
return ret;
}