From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6939 64.71.128.0/18 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.io-splice.general Subject: [PATCH] vmsplice: more consistent fileno retry handling Date: Sat, 19 Jan 2013 08:23:45 +0000 Message-ID: <20130119082345.GA5562@dcvr.yhbt.net> References: <20130119082345.GA5562@dcvr.yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1358583837 16485 80.91.229.3 (19 Jan 2013 08:23:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Jan 2013 08:23:57 +0000 (UTC) To: ruby.io.splice@librelist.org Original-X-From: ruby.io.splice@librelist.org Sat Jan 19 09:24:16 2013 Return-path: Envelope-to: gclrig-ruby.io.splice@m.gmane.org In-Reply-To: <20130119082345.GA5562@dcvr.yhbt.net> List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: ruby.io.splice@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.io-splice.general:38 Archived-At: Received: from zedshaw.xen.prgmr.com ([64.71.167.205]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TwTip-0000aa-Im for gclrig-ruby.io.splice@m.gmane.org; Sat, 19 Jan 2013 09:24:15 +0100 Received: from zedshaw.xen.prgmr.com (localhost [IPv6:::1]) by zedshaw.xen.prgmr.com (Postfix) with ESMTP id A5F2521FE7C for ; Sat, 19 Jan 2013 08:37:07 +0000 (UTC) While vmsplice is hardly useful, its FD-closed-while-GVL-less handling should be as good as our splice and tee wrappers. --- ext/io_splice/io_splice_ext.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ext/io_splice/io_splice_ext.c b/ext/io_splice/io_splice_ext.c index 876d07d..e429266 100644 --- a/ext/io_splice/io_splice_ext.c +++ b/ext/io_splice/io_splice_ext.c @@ -493,6 +493,7 @@ static VALUE my_vmsplice(int argc, VALUE * argv, VALUE self) ssize_t left; struct vmsplice_args a; struct iovec iov; + ssize_t n; VALUE io, data, flags; @@ -513,21 +514,19 @@ static VALUE my_vmsplice(int argc, VALUE * argv, VALUE self) "(expected a String or Array of strings)", rb_obj_classname(data)); } - a.fd = my_fileno(io); + a.flags = NIL_P(flags) ? 0 : NUM2UINT(flags); for (;;) { - ssize_t n = (ssize_t)io_run(nogvl_vmsplice, &a); + a.fd = check_fileno(io); + n = (ssize_t)io_run(nogvl_vmsplice, &a); if (n == -1) { if (errno == EAGAIN) { - if (a.flags & SPLICE_F_NONBLOCK) { + if (a.flags & SPLICE_F_NONBLOCK) rb_sys_fail("vmsplice"); - } else { - a.fd = check_fileno(io); - if (rb_io_wait_writable(a.fd)) - continue; - } + if (rb_io_wait_writable(check_fileno(io))) + continue; /* fall through on error */ } /* @@ -537,10 +536,8 @@ static VALUE my_vmsplice(int argc, VALUE * argv, VALUE self) */ if (rv > 0) break; - if (errno == EINTR) { - a.fd = check_fileno(io); + if (errno == EINTR) continue; - } rb_sys_fail("vmsplice"); } -- 1.8.1.1.253.g2934a48