summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--ext/socket/ancdata.c10
-rw-r--r--test/socket/test_nonblock.rb2
-rw-r--r--test/socket/test_socket.rb2
4 files changed, 16 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 51663eb715e..2957f82704b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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,
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 8759d3390d4..db5e7fd6570 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -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);
diff --git a/test/socket/test_nonblock.rb b/test/socket/test_nonblock.rb
index 59bd4f3aaca..d494f91c414 100644
--- a/test/socket/test_nonblock.rb
+++ b/test/socket/test_nonblock.rb
@@ -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
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb
index be6dabf3d7e..9b0f896faf5 100644
--- a/test/socket/test_socket.rb
+++ b/test/socket/test_socket.rb
@@ -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