ext/kgio/read_write.c in kgio-2.3.3 vs ext/kgio/read_write.c in kgio-2.4.0
- old
+ new
@@ -66,26 +66,30 @@
a->len = NUM2LONG(length);
if (NIL_P(a->buf)) {
a->buf = rb_str_new(NULL, a->len);
} else {
StringValue(a->buf);
+ rb_str_modify(a->buf);
rb_str_resize(a->buf, a->len);
}
a->ptr = RSTRING_PTR(a->buf);
}
static int read_check(struct io_args *a, long n, const char *msg, int io_wait)
{
if (n == -1) {
- if (errno == EINTR)
+ if (errno == EINTR) {
+ a->fd = my_fileno(a->io);
return -1;
+ }
rb_str_set_len(a->buf, 0);
if (errno == EAGAIN) {
if (io_wait) {
(void)kgio_call_wait_readable(a->io);
/* buf may be modified in other thread/fiber */
+ rb_str_modify(a->buf);
rb_str_resize(a->buf, a->len);
a->ptr = RSTRING_PTR(a->buf);
return -1;
} else {
a->buf = sym_wait_readable;
@@ -305,12 +309,14 @@
{
if (a->len == n) {
done:
a->buf = Qnil;
} else if (n == -1) {
- if (errno == EINTR)
+ if (errno == EINTR) {
+ a->fd = my_fileno(a->io);
return -1;
+ }
if (errno == EAGAIN) {
long written = RSTRING_LEN(a->buf) - a->len;
if (io_wait) {
(void)kgio_call_wait_writable(a->io);
@@ -368,11 +374,11 @@
}
/*
* call-seq:
*
- * io.kgio_trywrite(str) -> nil or :wait_writable
+ * io.kgio_trywrite(str) -> nil, String or :wait_writable
*
* Returns nil if the write was completed in full.
*
* Returns a String containing the unwritten portion if EAGAIN
* was encountered, but some portion was successfully written.
@@ -449,10 +455,10 @@
}
/*
* call-seq:
*
- * Kgio.trywrite(io, str) -> nil or :wait_writable
+ * Kgio.trywrite(io, str) -> nil, String or :wait_writable
*
* Returns nil if the write was completed in full.
*
* Returns a String containing the unwritten portion if EAGAIN
* was encountered, but some portion was successfully written.