From 0283c3d0bba4f4fca5da128bb0544e5745778cb3 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 24 Jul 2011 11:04:11 +0000 Subject: [PATCH] * ext/socket/extconf.rb: fix the recvmsg test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/socket/extconf.rb | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d731d1215..eff77932c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Jul 24 20:02:31 2011 Tanaka Akira + + * ext/socket/extconf.rb: fix the recvmsg test. + Sun Jul 24 08:42:51 2011 Tanaka Akira * ext/socket/extconf.rb: test recvmsg allocates file descriptors for diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 741554de4b..f8354493bb 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -147,7 +147,7 @@ int main(int argc, char *argv[]) } s_cmsg, r_cmsg; struct iovec s_iov, r_iov; char s_buf[1], r_buf[1]; - struct stat statbuf; + struct stat s_statbuf, r_statbuf; s_fd = 0; /* stdin */ @@ -198,13 +198,23 @@ int main(int argc, char *argv[]) if (r_msg.msg_controllen < CMSG_LEN(sizeof(int))) exit(EXIT_FAILURE); if (r_cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(int))) exit(EXIT_FAILURE); - memcpy((char *)&r_fd, CMSG_DATA(&s_cmsg.hdr), sizeof(int)); + memcpy((char *)&r_fd, CMSG_DATA(&r_cmsg.hdr), sizeof(int)); if (r_fd < 0) exit(EXIT_FAILURE); - ret = fstat(r_fd, &statbuf); + if (r_fd == s_fd) exit(EXIT_FAILURE); + + ret = fstat(s_fd, &s_statbuf); if (ret == -1) { exit(EXIT_FAILURE); } + ret = fstat(r_fd, &r_statbuf); + if (ret == -1) { exit(EXIT_FAILURE); } + + if (s_statbuf.st_dev != r_statbuf.st_dev || + s_statbuf.st_ino != r_statbuf.st_ino) { + exit(EXIT_FAILURE); + } + return EXIT_SUCCESS; } EOF