diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-20 22:11:56 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-20 22:11:56 +0000 |
commit | fdcac09849a7644618a202215a2615f1f029b48b (patch) | |
tree | 8f159f32393bbf032ed13c72c857587981e66568 /ext/socket | |
parent | ea6044ea364bbf5a89ee203182f1b093f20c51b3 (diff) |
* backport r32579, r32581, r32587 by akr and r32588 by kazu.
r32579:
* io.c (rb_update_max_fd): new function.
* internal.h (rb_update_max_fd): declare rb_update_max_fd.
* thread_pthread.c (rb_thread_create_timer_thread): update max fd when
timer thread pipe is created.
r32581:
* io.c (UPDATE_MAXFD): removed.
r32587:
* include/ruby/intern.h (rb_update_max_fd): declaration moved from
internal.h.
* file.c: ditto.
* io.c: call rb_update_max_fd for each new fds.
* process.c: ditto.
* random.c: ditto.
* ruby.c: ditto.
* ext/io/console/console.c: ditto.
* ext/openssl/ossl_bio.c: ditto.
* ext/pty/pty.c: ditto.
* ext/socket/init.c: ditto.
* ext/socket/socket.c: ditto.
* ext/socket/ancdata.c: ditto.
* ext/socket/unixsocket.c: ditto.
r32588:
* io.c (rb_update_max_fd): remove parentheses. they are not in
macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/ancdata.c | 2 | ||||
-rw-r--r-- | ext/socket/init.c | 5 | ||||
-rw-r--r-- | ext/socket/socket.c | 2 | ||||
-rw-r--r-- | ext/socket/unixsocket.c | 1 |
4 files changed, 10 insertions, 0 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c index 81394371ff..89a8921414 100644 --- a/ext/socket/ancdata.c +++ b/ext/socket/ancdata.c @@ -1384,6 +1384,7 @@ discard_cmsg(struct cmsghdr *cmh, char *msg_end) int *end = (int *)((char *)cmh + cmh->cmsg_len); while ((char *)fdp + sizeof(int) <= (char *)end && (char *)fdp + sizeof(int) <= msg_end) { + rb_update_max_fd(*fdp); close(*fdp); fdp++; } @@ -1426,6 +1427,7 @@ make_io_for_unix_rights(VALUE ctl, struct cmsghdr *cmh, char *msg_end) VALUE io; if (fstat(fd, &stbuf) == -1) rb_raise(rb_eSocket, "invalid fd in SCM_RIGHTS"); + rb_update_max_fd(fd); if (S_ISSOCK(stbuf.st_mode)) io = rsock_init_sock(rb_obj_alloc(rb_cSocket), fd); else diff --git a/ext/socket/init.c b/ext/socket/init.c index e55736cabe..8df1aee9bf 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -48,6 +48,7 @@ rsock_init_sock(VALUE sock, int fd) if (fstat(fd, &sbuf) < 0) rb_sys_fail(0); + rb_update_max_fd(fd); if (!S_ISSOCK(sbuf.st_mode)) rb_raise(rb_eArgError, "not a socket file descriptor"); #else @@ -250,6 +251,8 @@ rsock_socket(int domain, int type, int proto) fd = socket(domain, type, proto); } } + if (0 <= fd) + rb_update_max_fd(fd); return fd; } @@ -463,6 +466,7 @@ rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, s } rb_sys_fail("accept(2)"); } + rb_update_max_fd(fd2); make_fd_nonblock(fd2); return rsock_init_sock(rb_obj_alloc(klass), fd2); } @@ -509,6 +513,7 @@ rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len) } rb_sys_fail(0); } + rb_update_max_fd(fd2); if (!klass) return INT2NUM(fd2); return rsock_init_sock(rb_obj_alloc(klass), fd2); } diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 63586fc002..c2743cd621 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -119,6 +119,8 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass) if (ret < 0) { rb_sys_fail("socketpair(2)"); } + rb_update_max_fd(sp[0]); + rb_update_max_fd(sp[1]); s1 = rsock_init_sock(rb_obj_alloc(klass), sp[0]); s2 = rsock_init_sock(rb_obj_alloc(klass), sp[1]); diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c index 88ffa60fb6..587caf88a0 100644 --- a/ext/socket/unixsocket.c +++ b/ext/socket/unixsocket.c @@ -383,6 +383,7 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock) #if FD_PASSING_BY_MSG_CONTROL memcpy(&fd, CMSG_DATA(&cmsg.hdr), sizeof(int)); #endif + rb_update_max_fd(fd); if (klass == Qnil) return INT2FIX(fd); |