* ext/socket/ancdata.c (bsock_recvmsg_internal): reduce code on
environments which have no control message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
288e892a10
commit
d89e09b308
@ -1,3 +1,8 @@
|
|||||||
|
Wed Feb 18 12:09:43 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/ancdata.c (bsock_recvmsg_internal): reduce code on
|
||||||
|
environments which have no control message.
|
||||||
|
|
||||||
Wed Feb 18 20:27:16 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Feb 18 20:27:16 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in (OBJCOPY): set ac_cv_prog_ac_ct_OBJCOPY to do nothing
|
* configure.in (OBJCOPY): set ac_cv_prog_ac_ct_OBJCOPY to do nothing
|
||||||
|
@ -1102,27 +1102,33 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
rb_io_t *fptr;
|
rb_io_t *fptr;
|
||||||
VALUE vmaxdatlen, vmaxctllen, vflags;
|
VALUE vmaxdatlen, vmaxctllen, vflags;
|
||||||
int grow_buffer;
|
int grow_buffer;
|
||||||
size_t maxdatlen, maxctllen;
|
size_t maxdatlen;
|
||||||
int flags, orig_flags;
|
int flags, orig_flags;
|
||||||
struct msghdr mh;
|
struct msghdr mh;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
#if defined(HAVE_ST_MSG_CONTROL)
|
|
||||||
struct cmsghdr *cmh;
|
|
||||||
#endif
|
|
||||||
struct sockaddr_storage namebuf;
|
struct sockaddr_storage namebuf;
|
||||||
char datbuf0[4096], *datbuf;
|
char datbuf0[4096], *datbuf;
|
||||||
char ctlbuf0[4096], *ctlbuf;
|
|
||||||
VALUE dat_str = Qnil;
|
VALUE dat_str = Qnil;
|
||||||
VALUE ctl_str = Qnil;
|
|
||||||
VALUE ret;
|
VALUE ret;
|
||||||
ssize_t ss;
|
ssize_t ss;
|
||||||
|
#if defined(HAVE_ST_MSG_CONTROL)
|
||||||
|
struct cmsghdr *cmh;
|
||||||
|
size_t maxctllen;
|
||||||
|
char ctlbuf0[4096], *ctlbuf;
|
||||||
|
VALUE ctl_str = Qnil;
|
||||||
|
#endif
|
||||||
|
|
||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "03", &vmaxdatlen, &vflags, &vmaxctllen);
|
rb_scan_args(argc, argv, "03", &vmaxdatlen, &vflags, &vmaxctllen);
|
||||||
|
|
||||||
maxdatlen = NIL_P(vmaxdatlen) ? sizeof(datbuf0) : NUM2SIZET(vmaxdatlen);
|
maxdatlen = NIL_P(vmaxdatlen) ? sizeof(datbuf0) : NUM2SIZET(vmaxdatlen);
|
||||||
|
#if defined(HAVE_ST_MSG_CONTROL)
|
||||||
maxctllen = NIL_P(vmaxctllen) ? sizeof(ctlbuf0) : NUM2SIZET(vmaxctllen);
|
maxctllen = NIL_P(vmaxctllen) ? sizeof(ctlbuf0) : NUM2SIZET(vmaxctllen);
|
||||||
|
#else
|
||||||
|
if (!NIL_P(vmaxctllen))
|
||||||
|
rb_raise(rb_eArgError, "control message not supported");
|
||||||
|
#endif
|
||||||
flags = NIL_P(vflags) ? 0 : NUM2INT(vflags);
|
flags = NIL_P(vflags) ? 0 : NUM2INT(vflags);
|
||||||
#ifdef MSG_DONTWAIT
|
#ifdef MSG_DONTWAIT
|
||||||
if (nonblock)
|
if (nonblock)
|
||||||
@ -1159,6 +1165,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 (maxctllen <= sizeof(ctlbuf0))
|
if (maxctllen <= sizeof(ctlbuf0))
|
||||||
ctlbuf = ctlbuf0;
|
ctlbuf = ctlbuf0;
|
||||||
else {
|
else {
|
||||||
@ -1168,6 +1175,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||||||
rb_str_resize(ctl_str, maxctllen);
|
rb_str_resize(ctl_str, maxctllen);
|
||||||
ctlbuf = RSTRING_PTR(ctl_str);
|
ctlbuf = RSTRING_PTR(ctl_str);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
memset(&mh, 0, sizeof(mh));
|
memset(&mh, 0, sizeof(mh));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user