diff --git a/ChangeLog b/ChangeLog index 612e8aa43a..c10e42d760 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jun 8 01:37:58 2008 Tanaka Akira + + * ext/socket/socket.c (s_accept_nonblock): make accepted fd + nonblocking. [ruby-talk:274079] + Sun Jun 8 01:28:42 2008 Nobuyoshi Nakada * win32/mkexports.rb: deal with __fastcall name decorations. diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 5c91c390ec..8558e99ee5 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -1424,6 +1424,24 @@ tcp_svr_init(argc, argv, sock) return init_inetsock(sock, Qnil, arg1, Qnil, Qnil, INET_SERVER); } +static void +make_fd_nonblock(int fd) +{ + int flags; +#ifdef F_GETFL + flags = fcntl(fd, F_GETFL); + if (flags == -1) { + rb_sys_fail(0); + } +#else + flags = 0; +#endif + flags |= O_NONBLOCK; + if (fcntl(fd, F_SETFL, flags) == -1) { + rb_sys_fail(0); + } +} + static VALUE s_accept_nonblock(VALUE klass, OpenFile *fptr, struct sockaddr *sockaddr, socklen_t *len) { @@ -1435,6 +1453,7 @@ s_accept_nonblock(VALUE klass, OpenFile *fptr, struct sockaddr *sockaddr, sockle if (fd2 < 0) { rb_sys_fail("accept(2)"); } + make_fd_nonblock(fd2); return init_sock(rb_obj_alloc(klass), fd2); } diff --git a/version.h b/version.h index 04cfbb4aa7..9756fe6290 100644 --- a/version.h +++ b/version.h @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2008-06-08" #define RUBY_VERSION_CODE 185 #define RUBY_RELEASE_CODE 20080608 -#define RUBY_PATCHLEVEL 134 +#define RUBY_PATCHLEVEL 135 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8