mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (internal_{read,write}_func, rb_{read,write}_internal):
preserve errno. a patch from Takehiro Kubo in [ruby-core:29340]. [ruby-core:28924] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f6b46f0779
commit
92de2ed517
2 changed files with 23 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
|||
Fri Apr 9 01:26:54 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (internal_{read,write}_func, rb_{read,write}_internal):
|
||||
preserve errno. a patch from Takehiro Kubo in [ruby-core:29340].
|
||||
[ruby-core:28924]
|
||||
|
||||
Fri Apr 9 01:12:07 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* lib/irb/completion.rb (CompletionProc): calling the method "methods"
|
||||
|
|
21
io.c
21
io.c
|
@ -530,6 +530,7 @@ wsplit_p(rb_io_t *fptr)
|
|||
|
||||
struct io_internal_struct {
|
||||
int fd;
|
||||
int saved_errno;
|
||||
void *buf;
|
||||
size_t capa;
|
||||
};
|
||||
|
@ -538,36 +539,48 @@ static VALUE
|
|||
internal_read_func(void *ptr)
|
||||
{
|
||||
struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
|
||||
return read(iis->fd, iis->buf, iis->capa);
|
||||
ssize_t ret = read(iis->fd, iis->buf, iis->capa);
|
||||
iis->saved_errno = errno;
|
||||
return (VALUE)ret;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
internal_write_func(void *ptr)
|
||||
{
|
||||
struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
|
||||
return write(iis->fd, iis->buf, iis->capa);
|
||||
ssize_t ret = write(iis->fd, iis->buf, iis->capa);
|
||||
iis->saved_errno = errno;
|
||||
return (VALUE)ret;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
rb_read_internal(int fd, void *buf, size_t count)
|
||||
{
|
||||
struct io_internal_struct iis;
|
||||
ssize_t ret;
|
||||
|
||||
iis.fd = fd;
|
||||
iis.buf = buf;
|
||||
iis.capa = count;
|
||||
|
||||
return (ssize_t)rb_thread_blocking_region(internal_read_func, &iis, RUBY_UBF_IO, 0);
|
||||
ret = (ssize_t)rb_thread_blocking_region(internal_read_func, &iis, RUBY_UBF_IO, 0);
|
||||
errno = iis.saved_errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
rb_write_internal(int fd, void *buf, size_t count)
|
||||
{
|
||||
struct io_internal_struct iis;
|
||||
ssize_t ret;
|
||||
|
||||
iis.fd = fd;
|
||||
iis.buf = buf;
|
||||
iis.capa = count;
|
||||
|
||||
return (ssize_t)rb_thread_blocking_region(internal_write_func, &iis, RUBY_UBF_IO, 0);
|
||||
ret = (ssize_t)rb_thread_blocking_region(internal_write_func, &iis, RUBY_UBF_IO, 0);
|
||||
errno = iis.saved_errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long
|
||||
|
|
Loading…
Reference in a new issue