Skip to content

Commit

Permalink
ext/socket: fix #1424. try to open file when can't convert to IO's ob…
Browse files Browse the repository at this point in the history
…ject.
  • Loading branch information
Watson1978 committed Nov 30, 2011
1 parent 7b84e0c commit bc2f90c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ext/socket/socket.c
Expand Up @@ -3062,13 +3062,13 @@ socket_sendfile(VALUE self, SEL sel, VALUE file, VALUE offset, VALUE len)
rb_io_t *socket;

GetOpenFile(self, socket);
if (TYPE(file) == T_STRING) {
file = rb_f_open(rb_cIO, 0, 1, &file);
VALUE io = rb_io_check_io(file);
if (NIL_P(io)) {
io = rb_f_open(rb_cIO, 0, 1, &file);
needs_to_close = true;
}

file = rb_io_check_io(file);
rb_io_t *source = ExtractIOStruct(file);
rb_io_t *source = ExtractIOStruct(io);
rb_io_check_closed(source);

if (sendfile(source->fd, socket->fd, to_offset, &to_write, NULL, 0) == -1) {
Expand Down

0 comments on commit bc2f90c

Please sign in to comment.