diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-21 12:02:45 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-21 12:02:45 +0000 |
commit | f0353afdc1f94393338ac07ed2dc02c71ed951c5 (patch) | |
tree | 936b5bd84bc9f297fd6a8d156c809fe6b70561dd /ext | |
parent | ff4e38fb32b0066135cbb3ef429d6dbe07eff4e6 (diff) |
* ext/socket/ancdata.c (discard_cmsg): workaround for MacOS X Lion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/socket/ancdata.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c index 89a8921414..61e0576e6b 100644 --- a/ext/socket/ancdata.c +++ b/ext/socket/ancdata.c @@ -1384,8 +1384,16 @@ 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); + /* + * xxx: nagachika said *fdp can be invalid fd on MacOS X Lion. + * This workaround using fstat is clearly wrong. + * we should investigate why *fdp contains invalid fd. + */ + struct stat buf; + if (fstat(*fdp, &buf) == 0) { + rb_update_max_fd(*fdp); + close(*fdp); + } fdp++; } } |