Make sure we return complete lines from readline() and fix regressions #944

wants to merge 11 commits into


None yet

5 participants


This should fix everything that was broken by the premature merge of my branch, as well as implementing the readline() change.

gerdr added some commits Mar 12, 2013
@gerdr gerdr Make readline() always return complete lines instead of partial ones,…
… even if we have to block
@gerdr gerdr adjust FIXME comment e084eba
@gerdr gerdr Next shot at fixing io_readline_encoded_string().
All regression should be gone and HTTP::Easy still works.
I also identified a potential problem already present in the
original code.
@gerdr gerdr Purge set_eof from IO subsystem.
Being at EOF is something the underlying system handle keeps track of, and not
something we should be able to affect from userspace.

If nobody deals with this pull request in the next three days, I will merge it. :)


Wow. That ended up being slightly more work that I set out to do.

Please wait with the merge to master until others have had time to review these changes.

In particular, the following semantics have changed:

  • get_bool(), eof() and is_open() share a single method implementation in the Handle superclass
  • eof() on sockets does something useful now: it checks if the last buffered read succeeded (or rather, didn't)
  • get_bool() checks if the handle is open instead of looking for EOF, which is imo the more useful behaviour for generic handle types, which necessitated changing a single test
  • the set_eof() IO vtable function is gone - it was a noop for most types and is an implementation detail that shouldn't be exposed

Stuff I still need to work on:

  • align io_read_encoded_string() with io_readline_encoded_string()
  • add tests for readline() with sockets, which should now work as expected for all edge cases I could come up with

Stuff to think about:

  • move flags from FileHandle and StringHandle to Handle, use PIO_F_EOF instead of PIO_BF_UNDERFLOW for sockets
  • generic implementations for IO vtable functions that can be shared

I'm taking a shot at the 'stuff to think about' in the branch

Parrot Virtual Machine member

What is the status of this? It is not clear to me what needs to happen to close this issue. Can somebody update the description with details?


The pull request as-is could in principle be merged: It test cleanly and fixes #942.

However, there's still some more stuff I want to do, in particular aligning io_read_encoded_string() with the new io_readline_encoded_string() semantics and adding tests.

I don't particularly like the factoring, though, which is why I started (which right now breaks GzipHandle but otherwise passes the tests as well).

I'll try to get back to this sooner rather than later, but no guarantees...

Parrot Virtual Machine member

Can you please give a status update about this, @gerdr ? Thank you!


hey @gerdr, there's still a pull request open for rakudo that references this bug (rakudo/rakudo#107).
Is the branch still interesting?

Parrot Virtual Machine member

I fixed up this branch in gerdr/socket-readline-gh944.
One blocker though: parrot_nci_thunk_gen hangs after having written the buffer. It could be the read from the pipe missing it's eof.

./parrot_nci_thunk_gen ... --output=src/glut_nci_thunks.c < src/glut_nci_thunks.nci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment