[前][次][番号順一覧][スレッド一覧]

ruby-changes:28572

From: akr <ko1@a...>
Date: Thu, 9 May 2013 20:48:41 +0900 (JST)
Subject: [ruby-changes:28572] akr:r40624 (trunk): * ext/socket/ancdata.c (bsock_sendmsg_internal): Always set

akr	2013-05-09 20:48:29 +0900 (Thu, 09 May 2013)

  New Revision: 40624

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40624

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/ancdata.c
    trunk/test/socket/test_nonblock.rb
    trunk/test/socket/test_socket.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40623)
+++ ChangeLog	(revision 40624)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu May  9 20:43:41 2013  Tanaka Akira  <akr@f...>
+
+	* 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@f...>
 
 	* ext/socket/rubysocket.h, ext/socket/unixsocket.c,
Index: ext/socket/ancdata.c
===================================================================
--- ext/socket/ancdata.c	(revision 40623)
+++ ext/socket/ancdata.c	(revision 40624)
@@ -1147,15 +1147,15 @@ bsock_sendmsg_internal(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1147
 #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 * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1490
     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 * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1524
 
     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);
Index: test/socket/test_nonblock.rb
===================================================================
--- test/socket/test_nonblock.rb	(revision 40623)
+++ test/socket/test_nonblock.rb	(revision 40624)
@@ -221,7 +221,7 @@ class TestSocketNonblock < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/socket/test_nonblock.rb#L221
           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
Index: test/socket/test_socket.rb
===================================================================
--- test/socket/test_socket.rb	(revision 40623)
+++ test/socket/test_socket.rb	(revision 40624)
@@ -410,7 +410,7 @@ class TestSocket < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/socket/test_socket.rb#L410
         }
       rescue NotImplementedError, Errno::ENOSYS
         skipped = true
-        skip "need sendmsg and recvmsg"
+        skip "need sendmsg and recvmsg: #{$!}"
       ensure
         if th
           if skipped

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]