summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-21 12:02:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-21 12:02:45 +0000
commitf0353afdc1f94393338ac07ed2dc02c71ed951c5 (patch)
tree936b5bd84bc9f297fd6a8d156c809fe6b70561dd
parentff4e38fb32b0066135cbb3ef429d6dbe07eff4e6 (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
-rw-r--r--ChangeLog5
-rw-r--r--ext/socket/ancdata.c12
2 files changed, 15 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 53a93735eb..ef890d1f71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jul 21 20:59:59 2011 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/ancdata.c (discard_cmsg): workaround for MacOS X Lion.
+
+
Thu Jul 21 07:07:57 2011 Tanaka Akira <akr@fsij.org>
* backport r32579, r32581, r32587 by akr and r32588 by kazu.
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++;
}
}