mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/socket.c (s_accept_nonblock): make accepted fd
nonblocking. [ruby-talk:274079] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a0e3752870
commit
297d2e05cb
2 changed files with 24 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Oct 15 01:15:09 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/socket.c (s_accept_nonblock): make accepted fd
|
||||
nonblocking. [ruby-talk:274079]
|
||||
|
||||
Sun Oct 14 17:31:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* encoding.c (rb_obj_encoding): rdoc update. a patch from David
|
||||
|
|
|
@ -1454,6 +1454,24 @@ tcp_svr_init(int argc, VALUE *argv, VALUE 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, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
|
||||
{
|
||||
|
@ -1465,6 +1483,7 @@ s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen
|
|||
if (fd2 < 0) {
|
||||
rb_sys_fail("accept(2)");
|
||||
}
|
||||
make_fd_nonblock(fd2);
|
||||
return init_sock(rb_obj_alloc(klass), fd2);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue