summaryrefslogtreecommitdiff
path: root/ext/socket/ancdata.c
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 /ext/socket/ancdata.c
parent9752864b888a368188afaaf103e44f6da054c7dc (diff)
* 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
Diffstat (limited to 'ext/socket/ancdata.c')
-rw-r--r--ext/socket/ancdata.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 89a8921..61e0576 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++;
}
}