ruby-changes:2208
From: ko1@a...
Date: 15 Oct 2007 01:19:08 +0900
Subject: [ruby-changes:2208] akr - Ruby:r13699 (ruby_1_8, trunk): * ext/socket/socket.c (s_accept_nonblock): make accepted fd
akr 2007-10-15 01:18:41 +0900 (Mon, 15 Oct 2007)
New Revision: 13699
Modified files:
branches/ruby_1_8/ChangeLog
branches/ruby_1_8/ext/socket/socket.c
trunk/ChangeLog
trunk/ext/socket/socket.c
Log:
* ext/socket/socket.c (s_accept_nonblock): make accepted fd
nonblocking. [ruby-talk:274079]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=13699&r2=13698
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13699&r2=13698
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/socket/socket.c?r1=13699&r2=13698
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/socket/socket.c?r1=13699&r2=13698
Index: ChangeLog
===================================================================
--- ChangeLog (revision 13698)
+++ ChangeLog (revision 13699)
@@ -1,3 +1,8 @@
+Mon Oct 15 01:15:09 2007 Tanaka Akira <akr@f...>
+
+ * ext/socket/socket.c (s_accept_nonblock): make accepted fd
+ nonblocking. [ruby-talk:274079]
+
Sun Oct 14 17:31:48 2007 Nobuyoshi Nakada <nobu@r...>
* encoding.c (rb_obj_encoding): rdoc update. a patch from David
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c (revision 13698)
+++ ext/socket/socket.c (revision 13699)
@@ -1454,6 +1454,24 @@
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 @@
if (fd2 < 0) {
rb_sys_fail("accept(2)");
}
+ make_fd_nonblock(fd2);
return init_sock(rb_obj_alloc(klass), fd2);
}
Index: ruby_1_8/ext/socket/socket.c
===================================================================
--- ruby_1_8/ext/socket/socket.c (revision 13698)
+++ ruby_1_8/ext/socket/socket.c (revision 13699)
@@ -1464,6 +1464,24 @@
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)
{
@@ -1475,6 +1493,7 @@
if (fd2 < 0) {
rb_sys_fail("accept(2)");
}
+ make_fd_nonblock(fd2);
return init_sock(rb_obj_alloc(klass), fd2);
}
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog (revision 13698)
+++ ruby_1_8/ChangeLog (revision 13699)
@@ -1,3 +1,8 @@
+Mon Oct 15 01:15:09 2007 Tanaka Akira <akr@f...>
+
+ * ext/socket/socket.c (s_accept_nonblock): make accepted fd
+ nonblocking. [ruby-talk:274079]
+
Sun Oct 14 04:08:34 2007 Nobuyoshi Nakada <nobu@r...>
* configure.in (AC_SYS_LARGEFILE): keep results also in command
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml