ruby-changes:10831
From: akr <ko1@a...>
Date: Wed, 18 Feb 2009 21:27:23 +0900 (JST)
Subject: [ruby-changes:10831] Ruby:r22401 (trunk): * ext/socket/ancdata.c (bsock_recvmsg_internal): reduce code on
akr 2009-02-18 21:27:13 +0900 (Wed, 18 Feb 2009) New Revision: 22401 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22401 Log: * ext/socket/ancdata.c (bsock_recvmsg_internal): reduce code on environments which have no control message. Modified files: trunk/ChangeLog trunk/ext/socket/ancdata.c Index: ChangeLog =================================================================== --- ChangeLog (revision 22400) +++ ChangeLog (revision 22401) @@ -1,3 +1,8 @@ +Wed Feb 18 12:09:43 2009 Tanaka Akira <akr@f...> + + * 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@r...> * configure.in (OBJCOPY): set ac_cv_prog_ac_ct_OBJCOPY to do nothing Index: ext/socket/ancdata.c =================================================================== --- ext/socket/ancdata.c (revision 22400) +++ ext/socket/ancdata.c (revision 22401) @@ -1102,27 +1102,33 @@ 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 @@ datbuf = RSTRING_PTR(dat_str); } +#if defined(HAVE_ST_MSG_CONTROL) if (maxctllen <= sizeof(ctlbuf0)) ctlbuf = ctlbuf0; else { @@ -1168,6 +1175,7 @@ rb_str_resize(ctl_str, maxctllen); ctlbuf = RSTRING_PTR(ctl_str); } +#endif memset(&mh, 0, sizeof(mh)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/