Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Consider buffered sockets at EOF if the last read failed

  • Loading branch information...
commit 265980fc3c7360fda92cbb15a010122a0b6a4d70 1 parent bf0701a
Gerhard R. authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/io/socket.c
11 src/io/socket.c
View
@@ -297,7 +297,8 @@ io_socket_flush(PARROT_INTERP, ARGMOD(PMC *handle))
=item C<static INTVAL io_socket_is_eof(PARROT_INTERP, PMC *handle)>
-Sockets are not "passed-the-end" so long as the connection is open. Return 0.
+Sockets are considered at EOF if the last buffered read failed to fill the
+buffer. Always return 0 for unbuffered sockets.
=cut
@@ -307,9 +308,11 @@ static INTVAL
io_socket_is_eof(PARROT_INTERP, ARGMOD(PMC *handle))
{
ASSERT_ARGS(io_socket_is_eof)
- UNUSED(interp);
- UNUSED(handle);
- return 0;
+ IO_BUFFER * const buffer = IO_GET_READ_BUFFER(interp, handle);
+ if (!buffer)
+ return 0;
+
+ return !!(buffer->flags & PIO_BF_UNDERFLOW);
}
/*
Please sign in to comment.
Something went wrong with that request. Please try again.