summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-02 14:06:19 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-02 14:06:19 +0000
commit40d07f25a3f86bc5a47d959b856b9db5f24fcb49 (patch)
tree738ae30ad851c5ab81375b3be69a1c39e585866a
parent7b32f66c6b6acbe2073402be1702ed3c60e7e5d6 (diff)
* ext/socket/socket.c (unix_send_io, unix_recv_io): support x86-64 and
IA64. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog11
-rw-r--r--ext/socket/socket.c42
2 files changed, 37 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 6a2b94d..f851de0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,14 @@
+Sat Jul 2 22:41:04 2005 Tanaka Akira <akr@m17n.org>
+
+ * ext/socket/socket.c (unix_send_io, unix_recv_io): support x86-64 and
+ IA64.
+
Sat Jul 2 17:06:23 2005 Tanaka Akira <akr@m17n.org>
- * defines.h (FLUSH_REGISTER_WINDOWS): defined for IA64.
- (flush_register_windows): declare flush_register_windows.
+ * defines.h (FLUSH_REGISTER_WINDOWS): defined for IA64.
+ (flush_register_windows): declare flush_register_windows.
- * eval.c (flush_register_windows): new function.
+ * eval.c (flush_register_windows): new function.
Fri Jul 1 17:48:52 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index d4edfd5..9d254e4 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1701,9 +1701,9 @@ unix_send_io(sock, val)
#if FD_PASSING_BY_MSG_CONTROL
msg.msg_control = (caddr_t)&cmsg;
- msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int);
+ msg.msg_controllen = CMSG_SPACE(sizeof(int));
msg.msg_flags = 0;
- cmsg.hdr.cmsg_len = sizeof(struct cmsghdr) + sizeof(int);
+ cmsg.hdr.cmsg_len = CMSG_SPACE(0) + sizeof(int);
cmsg.hdr.cmsg_level = SOL_SOCKET;
cmsg.hdr.cmsg_type = SCM_RIGHTS;
cmsg.fd = fd;
@@ -1776,9 +1776,9 @@ unix_recv_io(argc, argv, sock)
#if FD_PASSING_BY_MSG_CONTROL
msg.msg_control = (caddr_t)&cmsg;
- msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int);
+ msg.msg_controllen = CMSG_SPACE(sizeof(int));
msg.msg_flags = 0;
- cmsg.hdr.cmsg_len = sizeof(struct cmsghdr) + sizeof(int);
+ cmsg.hdr.cmsg_len = CMSG_SPACE(0) + sizeof(int);
cmsg.hdr.cmsg_level = SOL_SOCKET;
cmsg.hdr.cmsg_type = SCM_RIGHTS;
cmsg.fd = -1;
@@ -1791,18 +1791,34 @@ unix_recv_io(argc, argv, sock)
if (recvmsg(fileno(fptr->f), &msg, 0) == -1)
rb_sys_fail("recvmsg(2)");
- if (
#if FD_PASSING_BY_MSG_CONTROL
- msg.msg_controllen != sizeof(struct cmsghdr) + sizeof(int) ||
- cmsg.hdr.cmsg_len != sizeof(struct cmsghdr) + sizeof(int) ||
- cmsg.hdr.cmsg_level != SOL_SOCKET ||
- cmsg.hdr.cmsg_type != SCM_RIGHTS
+ if (msg.msg_controllen != CMSG_SPACE(sizeof(int))) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (msg_controllen : %d != %d)",
+ msg.msg_controllen, CMSG_SPACE(sizeof(int)));
+ }
+ if (cmsg.hdr.cmsg_len != CMSG_SPACE(0) + sizeof(int)) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (cmsg_len : %d != %d)",
+ cmsg.hdr.cmsg_len, CMSG_SPACE(0) + sizeof(int));
+ }
+ if (cmsg.hdr.cmsg_level != SOL_SOCKET) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (cmsg_level : %d != %d)",
+ cmsg.hdr.cmsg_level, SOL_SOCKET);
+ }
+ if (cmsg.hdr.cmsg_type != SCM_RIGHTS) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (cmsg_type : %d != %d)",
+ cmsg.hdr.cmsg_type, SCM_RIGHTS);
+ }
#else
- msg.msg_accrightslen != sizeof(fd)
-#endif
- ) {
- rb_raise(rb_eSocket, "file descriptor was not passed");
+ if (msg.msg_accrightslen != sizeof(fd)) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (accrightslen) : %d != %d",
+ msg.msg_accrightslen, sizeof(fd));
}
+#endif
#if FD_PASSING_BY_MSG_CONTROL
fd = cmsg.fd;