* 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/trunk@8702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2005-07-02 13:45:08 +00:00
Родитель bd5487e383
Коммит ddbe529c62
3 изменённых файлов: 49 добавлений и 26 удалений

Просмотреть файл

@ -1,3 +1,8 @@
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.

Просмотреть файл

@ -1779,9 +1779,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;
@ -1841,9 +1841,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;
@ -1856,18 +1856,34 @@ unix_recv_io(argc, argv, sock)
if (recvmsg(fptr->fd, &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
#else
msg.msg_accrightslen != sizeof(fd)
#endif
) {
rb_raise(rb_eSocket, "file descriptor was not passed");
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
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;

Просмотреть файл

@ -9,20 +9,22 @@ class TestUNIXSocket < Test::Unit::TestCase
r1, w = IO.pipe
s1, s2 = UNIXSocket.pair
begin
s1.send_io r1
s1.send_io(nil)
rescue NotImplementedError
s1.close
assert_raise(NotImplementedError) { s2.recv_io }
return
end
rescue TypeError
s1.send_io(r1)
r2 = s2.recv_io
assert_equal(r1.stat.ino, r2.stat.ino)
assert_not_equal(r1.fileno, r2.fileno)
w.syswrite "a"
assert_equal("a", r2.sysread(10))
ensure
s1.close if s1
s2.close if s2
r1.close if r1
r2.close if r2
w.close if w
s1.close
s2.close
w.close
r1.close
r2.close if r2 && !r2.closed?
end
end
end if defined?(UNIXSocket)