1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/socket/ancdata.c (bsock_sendmsg_internal): Always set

controls_num to raise NotImplementedError appropriately.
  (bsock_recvmsg_internal): Raise NotImplementedError if
  :scm_rights=>true is given on platforms which don't have
  4.4BSD style control message.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-05-09 11:48:29 +00:00
parent a5e6d48dfb
commit adb575e21e
4 changed files with 16 additions and 6 deletions

View file

@ -1,3 +1,11 @@
Thu May 9 20:43:41 2013 Tanaka Akira <akr@fsij.org>
* ext/socket/ancdata.c (bsock_sendmsg_internal): Always set
controls_num to raise NotImplementedError appropriately.
(bsock_recvmsg_internal): Raise NotImplementedError if
:scm_rights=>true is given on platforms which don't have
4.4BSD style control message.
Thu May 9 12:06:07 2013 Tanaka Akira <akr@fsij.org>
* ext/socket/rubysocket.h, ext/socket/unixsocket.c,

View file

@ -1147,15 +1147,15 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
#endif
data = vflags = dest_sockaddr = Qnil;
controls_num = 0;
if (argc == 0)
rb_raise(rb_eArgError, "mesg argument required");
data = argv[0];
if (1 < argc) vflags = argv[1];
if (2 < argc) dest_sockaddr = argv[2];
controls_num = argc - 3;
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
if (3 < argc) { controls_ptr = &argv[3]; controls_num = argc - 3; }
if (3 < argc) { controls_ptr = &argv[3]; }
#endif
StringValue(data);
@ -1490,8 +1490,8 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
VALUE dat_str = Qnil;
VALUE ret;
ssize_t ss;
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
int request_scm_rights;
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
struct cmsghdr *cmh;
size_t maxctllen;
union {
@ -1524,10 +1524,12 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
grow_buffer = NIL_P(vmaxdatlen) || NIL_P(vmaxctllen);
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
request_scm_rights = 0;
if (!NIL_P(vopts) && RTEST(rb_hash_aref(vopts, ID2SYM(rb_intern("scm_rights")))))
request_scm_rights = 1;
#if !defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
if (request_scm_rights)
rb_raise(rb_eNotImpError, "control message for recvmsg is unimplemented");
#endif
GetOpenFile(sock, fptr);

View file

@ -221,7 +221,7 @@ class TestSocketNonblock < Test::Unit::TestCase
s1.sendmsg_nonblock("a" * 100000)
}
rescue NotImplementedError, Errno::ENOSYS
skip "sendmsg not implemented on this platform."
skip "sendmsg not implemented on this platform: #{$!}"
rescue Errno::EMSGSIZE
# UDP has 64K limit (if no Jumbograms). No problem.
rescue Errno::EWOULDBLOCK

View file

@ -410,7 +410,7 @@ class TestSocket < Test::Unit::TestCase
}
rescue NotImplementedError, Errno::ENOSYS
skipped = true
skip "need sendmsg and recvmsg"
skip "need sendmsg and recvmsg: #{$!}"
ensure
if th
if skipped