aboutsummaryrefslogtreecommitdiffstats
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
commit272322bedeecfc0ef908e4746df4fea9b5cf90a3 (patch)
tree2e91a7c5a394b730c02f52ae72139df5c2409c5c
parent9752864b888a368188afaaf103e44f6da054c7dc (diff)
downloadruby-272322bedeecfc0ef908e4746df4fea9b5cf90a3.tar.gz
* ext/socket/ancdata.c (discard_cmsg): workaround for MacOS X Lion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--ext/socket/ancdata.c12
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ab9eb26b5c..deeabd84c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+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 20:02:11 2011 Yusuke Endoh <mame@tsg.ne.jp>
* thread.c (set_trace_func, thread_set_trace_func_m): reset tracing
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++;
}
}