* ext/socket/rubysocket.h, ext/socket/unixsocket.c,
ext/socket/ancdata.c: Use HAVE_STRUCT_MSGHDR_MSG_CONTROL instead of HAVE_ST_MSG_CONTROL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
029ad63b0b
commit
a5e6d48dfb
@ -1,3 +1,9 @@
|
|||||||
|
Thu May 9 12:06:07 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/rubysocket.h, ext/socket/unixsocket.c,
|
||||||
|
ext/socket/ancdata.c: Use HAVE_STRUCT_MSGHDR_MSG_CONTROL instead
|
||||||
|
of HAVE_ST_MSG_CONTROL.
|
||||||
|
|
||||||
Thu May 9 11:30:02 2013 Zachary Scott <zachary@zacharyscott.net>
|
Thu May 9 11:30:02 2013 Zachary Scott <zachary@zacharyscott.net>
|
||||||
|
|
||||||
* string.c: Add call-seq alias for String#=== [Bug #8381]
|
* string.c: Add call-seq alias for String#=== [Bug #8381]
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
static VALUE rb_cAncillaryData;
|
static VALUE rb_cAncillaryData;
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -1132,7 +1132,7 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
int controls_num;
|
int controls_num;
|
||||||
struct msghdr mh;
|
struct msghdr mh;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
volatile VALUE controls_str = 0;
|
volatile VALUE controls_str = 0;
|
||||||
VALUE *controls_ptr = NULL;
|
VALUE *controls_ptr = NULL;
|
||||||
int family;
|
int family;
|
||||||
@ -1142,7 +1142,7 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
|
|
||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
GetOpenFile(sock, fptr);
|
GetOpenFile(sock, fptr);
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
family = rsock_getfamily(fptr->fd);
|
family = rsock_getfamily(fptr->fd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1154,14 +1154,14 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
data = argv[0];
|
data = argv[0];
|
||||||
if (1 < argc) vflags = argv[1];
|
if (1 < argc) vflags = argv[1];
|
||||||
if (2 < argc) dest_sockaddr = argv[2];
|
if (2 < argc) dest_sockaddr = argv[2];
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#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]; controls_num = argc - 3; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
StringValue(data);
|
StringValue(data);
|
||||||
|
|
||||||
if (controls_num) {
|
if (controls_num) {
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
int i;
|
int i;
|
||||||
size_t last_pad = 0;
|
size_t last_pad = 0;
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
@ -1264,7 +1264,7 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
mh.msg_iov = &iov;
|
mh.msg_iov = &iov;
|
||||||
iov.iov_base = RSTRING_PTR(data);
|
iov.iov_base = RSTRING_PTR(data);
|
||||||
iov.iov_len = RSTRING_LEN(data);
|
iov.iov_len = RSTRING_LEN(data);
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
if (controls_str) {
|
if (controls_str) {
|
||||||
mh.msg_control = RSTRING_PTR(controls_str);
|
mh.msg_control = RSTRING_PTR(controls_str);
|
||||||
mh.msg_controllen = RSTRING_SOCKLEN(controls_str);
|
mh.msg_controllen = RSTRING_SOCKLEN(controls_str);
|
||||||
@ -1396,7 +1396,7 @@ rb_recvmsg(int fd, struct msghdr *msg, int flags)
|
|||||||
return (ssize_t)rb_thread_call_without_gvl(nogvl_recvmsg_func, &args, RUBY_UBF_IO, 0);
|
return (ssize_t)rb_thread_call_without_gvl(nogvl_recvmsg_func, &args, RUBY_UBF_IO, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
static void
|
static void
|
||||||
discard_cmsg(struct cmsghdr *cmh, char *msg_end, int msg_peek_p)
|
discard_cmsg(struct cmsghdr *cmh, char *msg_end, int msg_peek_p)
|
||||||
{
|
{
|
||||||
@ -1428,7 +1428,7 @@ discard_cmsg(struct cmsghdr *cmh, char *msg_end, int msg_peek_p)
|
|||||||
void
|
void
|
||||||
rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p)
|
rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
struct cmsghdr *cmh;
|
struct cmsghdr *cmh;
|
||||||
char *msg_end;
|
char *msg_end;
|
||||||
|
|
||||||
@ -1443,7 +1443,7 @@ rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
static void
|
static void
|
||||||
make_io_for_unix_rights(VALUE ctl, struct cmsghdr *cmh, char *msg_end)
|
make_io_for_unix_rights(VALUE ctl, struct cmsghdr *cmh, char *msg_end)
|
||||||
{
|
{
|
||||||
@ -1490,7 +1490,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
VALUE dat_str = Qnil;
|
VALUE dat_str = Qnil;
|
||||||
VALUE ret;
|
VALUE ret;
|
||||||
ssize_t ss;
|
ssize_t ss;
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
int request_scm_rights;
|
int request_scm_rights;
|
||||||
struct cmsghdr *cmh;
|
struct cmsghdr *cmh;
|
||||||
size_t maxctllen;
|
size_t maxctllen;
|
||||||
@ -1509,7 +1509,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
rb_scan_args(argc, argv, "03:", &vmaxdatlen, &vflags, &vmaxctllen, &vopts);
|
rb_scan_args(argc, argv, "03:", &vmaxdatlen, &vflags, &vmaxctllen, &vopts);
|
||||||
|
|
||||||
maxdatlen = NIL_P(vmaxdatlen) ? sizeof(datbuf0) : NUM2SIZET(vmaxdatlen);
|
maxdatlen = NIL_P(vmaxdatlen) ? sizeof(datbuf0) : NUM2SIZET(vmaxdatlen);
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
maxctllen = NIL_P(vmaxctllen) ? sizeof(ctlbuf0) : NUM2SIZET(vmaxctllen);
|
maxctllen = NIL_P(vmaxctllen) ? sizeof(ctlbuf0) : NUM2SIZET(vmaxctllen);
|
||||||
#else
|
#else
|
||||||
if (!NIL_P(vmaxctllen))
|
if (!NIL_P(vmaxctllen))
|
||||||
@ -1524,7 +1524,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
|
|
||||||
grow_buffer = NIL_P(vmaxdatlen) || NIL_P(vmaxctllen);
|
grow_buffer = NIL_P(vmaxdatlen) || NIL_P(vmaxctllen);
|
||||||
|
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
request_scm_rights = 0;
|
request_scm_rights = 0;
|
||||||
if (!NIL_P(vopts) && RTEST(rb_hash_aref(vopts, ID2SYM(rb_intern("scm_rights")))))
|
if (!NIL_P(vopts) && RTEST(rb_hash_aref(vopts, ID2SYM(rb_intern("scm_rights")))))
|
||||||
request_scm_rights = 1;
|
request_scm_rights = 1;
|
||||||
@ -1535,7 +1535,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
rb_raise(rb_eIOError, "recvmsg for buffered IO");
|
rb_raise(rb_eIOError, "recvmsg for buffered IO");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HAVE_ST_MSG_CONTROL)
|
#if !defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
if (grow_buffer) {
|
if (grow_buffer) {
|
||||||
int socktype;
|
int socktype;
|
||||||
socklen_t optlen = (socklen_t)sizeof(socktype);
|
socklen_t optlen = (socklen_t)sizeof(socktype);
|
||||||
@ -1558,7 +1558,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
datbuf = RSTRING_PTR(dat_str);
|
datbuf = RSTRING_PTR(dat_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
if (maxctllen <= sizeof(ctlbuf0))
|
if (maxctllen <= sizeof(ctlbuf0))
|
||||||
ctlbuf = ctlbuf0.bytes;
|
ctlbuf = ctlbuf0.bytes;
|
||||||
else {
|
else {
|
||||||
@ -1581,7 +1581,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
iov.iov_base = datbuf;
|
iov.iov_base = datbuf;
|
||||||
iov.iov_len = maxdatlen;
|
iov.iov_len = maxdatlen;
|
||||||
|
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
mh.msg_control = ctlbuf;
|
mh.msg_control = ctlbuf;
|
||||||
mh.msg_controllen = (socklen_t)maxctllen;
|
mh.msg_controllen = (socklen_t)maxctllen;
|
||||||
#endif
|
#endif
|
||||||
@ -1603,7 +1603,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
if (ss == -1) {
|
if (ss == -1) {
|
||||||
if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
|
if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
|
||||||
rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvmsg(2) would block");
|
rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvmsg(2) would block");
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
if (!gc_done && (errno == EMFILE || errno == EMSGSIZE)) {
|
if (!gc_done && (errno == EMFILE || errno == EMSGSIZE)) {
|
||||||
/*
|
/*
|
||||||
* When SCM_RIGHTS hit the file descriptors limit:
|
* When SCM_RIGHTS hit the file descriptors limit:
|
||||||
@ -1622,7 +1622,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
|
|
||||||
if (grow_buffer) {
|
if (grow_buffer) {
|
||||||
int grown = 0;
|
int grown = 0;
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
if (NIL_P(vmaxdatlen) && (mh.msg_flags & MSG_TRUNC)) {
|
if (NIL_P(vmaxdatlen) && (mh.msg_flags & MSG_TRUNC)) {
|
||||||
if (SIZE_MAX/2 < maxdatlen)
|
if (SIZE_MAX/2 < maxdatlen)
|
||||||
rb_raise(rb_eArgError, "max data length too big");
|
rb_raise(rb_eArgError, "max data length too big");
|
||||||
@ -1680,14 +1680,14 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
|
|
||||||
ret = rb_ary_new3(3, dat_str,
|
ret = rb_ary_new3(3, dat_str,
|
||||||
rsock_io_socket_addrinfo(sock, mh.msg_name, mh.msg_namelen),
|
rsock_io_socket_addrinfo(sock, mh.msg_name, mh.msg_namelen),
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
INT2NUM(mh.msg_flags)
|
INT2NUM(mh.msg_flags)
|
||||||
#else
|
#else
|
||||||
Qnil
|
Qnil
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
family = rsock_getfamily(fptr->fd);
|
family = rsock_getfamily(fptr->fd);
|
||||||
if (mh.msg_controllen) {
|
if (mh.msg_controllen) {
|
||||||
char *msg_end = (char *)mh.msg_control + mh.msg_controllen;
|
char *msg_end = (char *)mh.msg_control + mh.msg_controllen;
|
||||||
@ -1797,7 +1797,7 @@ rsock_bsock_recvmsg_nonblock(int argc, VALUE *argv, VALUE sock)
|
|||||||
void
|
void
|
||||||
rsock_init_ancdata(void)
|
rsock_init_ancdata(void)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||||||
/*
|
/*
|
||||||
* Document-class: Socket::AncillaryData
|
* Document-class: Socket::AncillaryData
|
||||||
*
|
*
|
||||||
|
@ -328,7 +328,7 @@ ssize_t rsock_recvmsg(int socket, struct msghdr *message, int flags);
|
|||||||
#define rsock_bsock_recvmsg_nonblock rb_f_notimplement
|
#define rsock_bsock_recvmsg_nonblock rb_f_notimplement
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ST_MSG_CONTROL
|
#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
|
||||||
void rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p);
|
void rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ unix_recvfrom(int argc, VALUE *argv, VALUE sock)
|
|||||||
return rsock_s_recvfrom(sock, argc, argv, RECV_UNIX);
|
return rsock_s_recvfrom(sock, argc, argv, RECV_UNIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_ST_MSG_CONTROL) && defined(SCM_RIGHTS)
|
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) && defined(SCM_RIGHTS)
|
||||||
#define FD_PASSING_BY_MSG_CONTROL 1
|
#define FD_PASSING_BY_MSG_CONTROL 1
|
||||||
#else
|
#else
|
||||||
#define FD_PASSING_BY_MSG_CONTROL 0
|
#define FD_PASSING_BY_MSG_CONTROL 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user