1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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:
akr 2009-02-18 12:27:13 +00:00
parent 288e892a10
commit d89e09b308
2 changed files with 19 additions and 6 deletions

View file

@ -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>
* configure.in (OBJCOPY): set ac_cv_prog_ac_ct_OBJCOPY to do nothing

View file

@ -1102,27 +1102,33 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
rb_io_t *fptr;
VALUE vmaxdatlen, vmaxctllen, vflags;
int grow_buffer;
size_t maxdatlen, maxctllen;
size_t maxdatlen;
int flags, orig_flags;
struct msghdr mh;
struct iovec iov;
#if defined(HAVE_ST_MSG_CONTROL)
struct cmsghdr *cmh;
#endif
struct sockaddr_storage namebuf;
char datbuf0[4096], *datbuf;
char ctlbuf0[4096], *ctlbuf;
VALUE dat_str = Qnil;
VALUE ctl_str = Qnil;
VALUE ret;
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_scan_args(argc, argv, "03", &vmaxdatlen, &vflags, &vmaxctllen);
maxdatlen = NIL_P(vmaxdatlen) ? sizeof(datbuf0) : NUM2SIZET(vmaxdatlen);
#if defined(HAVE_ST_MSG_CONTROL)
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);
#ifdef MSG_DONTWAIT
if (nonblock)
@ -1159,6 +1165,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
datbuf = RSTRING_PTR(dat_str);
}
#if defined(HAVE_ST_MSG_CONTROL)
if (maxctllen <= sizeof(ctlbuf0))
ctlbuf = ctlbuf0;
else {
@ -1168,6 +1175,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
rb_str_resize(ctl_str, maxctllen);
ctlbuf = RSTRING_PTR(ctl_str);
}
#endif
memset(&mh, 0, sizeof(mh));