From: Eric Wong <normalperson@yhbt.net>
To: ruby.io.splice@librelist.org
Subject: [PATCH] vmsplice: more consistent fileno retry handling
Date: Sat, 19 Jan 2013 08:23:45 +0000 [thread overview]
Message-ID: <20130119082345.GA5562@dcvr.yhbt.net> (raw)
In-Reply-To: <20130119082345.GA5562@dcvr.yhbt.net>
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
parent reply other threads:[~2013-01-19 8:24 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20130119082345.GA5562@dcvr.yhbt.net>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/ruby_io_splice/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130119082345.GA5562@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=ruby.io.splice@librelist.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/ruby_io_splice.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).