* ext/socket/ancdata.c (bsock_recvmsg_internal): gc when SCM_RIGHTS

hit the file descriptor limit.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-02-21 16:49:44 +00:00
parent 9cfe35ad50
commit ad2f293d4f
2 changed files with 29 additions and 2 deletions

View File

@ -1,3 +1,8 @@
Sun Feb 22 01:48:51 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/ancdata.c (bsock_recvmsg_internal): gc when SCM_RIGHTS
hit the file descriptor limit.
Sun Feb 22 00:51:58 2009 Tanaka Akira <akr@fsij.org>
* io.c (io_getpartial): error message describes what should be

View File

@ -1202,6 +1202,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
char *ctlbuf;
VALUE ctl_str = Qnil;
int family;
int gc_done = 0;
#endif
rb_secure(4);
@ -1296,6 +1297,16 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
if (ss == -1) {
if (nonblock && errno == EWOULDBLOCK)
rb_sys_fail("recvmsg(2) WANT_READ");
#if defined(HAVE_ST_MSG_CONTROL)
if (errno == EMFILE && !gc_done) {
/* SCM_RIGHTS hit the file descriptors limit, maybe. */
gc_and_retry:
discard_cmsg_resource(&mh);
rb_gc();
gc_done = 1;
goto retry;
}
#endif
rb_sys_fail("recvmsg(2)");
}
@ -1307,8 +1318,19 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
grown = 1;
}
if (NIL_P(vmaxctllen) && (mh.msg_flags & MSG_CTRUNC)) {
maxctllen *= 2;
grown = 1;
#define BIG_ENOUGH_SPACE 65536
if (BIG_ENOUGH_SPACE < maxctllen &&
mh.msg_controllen < maxctllen - BIG_ENOUGH_SPACE) {
/* there are big space bug truncated.
* file descriptors limit? */
if (!gc_done)
goto gc_and_retry;
}
else {
maxctllen *= 2;
grown = 1;
}
#undef BIG_ENOUGH_SPACE
}
#else
if (NIL_P(vmaxdatlen) && ss != -1 && ss == iov.iov_len) {