summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-09 11:48:29 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-09 11:48:29 +0000
commitadb575e21e176f73caa79838e98c8720269f12e2 (patch)
treec844f2effc9d518c764a2709e1db4caa20d8fda3 /ext
parenta5e6d48dfbd13f245eaa063c794e83c91aa5606a (diff)
* 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
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/ancdata.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 8759d3390d..db5e7fd657 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);