Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aio hang #291

Closed
prpr19xx opened this issue Jan 31, 2024 · 3 comments
Closed

aio hang #291

prpr19xx opened this issue Jan 31, 2024 · 3 comments

Comments

@prpr19xx
Copy link
Contributor

With ad72004, this produces the expected result:

. set f [socket stream www.google.com:80]
::aio.sock4
. $f puts -nonewline "GET / HTTP/1.1\r\n"
. $f puts -nonewline "Host: www.google.com\r\n"
. $f puts -nonewline "Connection: close\r\n"
. $f puts -nonewline "\r\n" 
. $f gets
HTTP/1.1 200 OK
.

With 41f431f and subsequent, it just hangs after the "$f gets", without producing any output, until presumably the server times it out and closes the connection.

@msteveb
Copy link
Owner

msteveb commented Jan 31, 2024

The socket is fully buffered so your puts typically won't be sent. Either make it line buffered or add '$f flush' after the last puts

@msteveb msteveb closed this as completed Jan 31, 2024
@prpr19xx
Copy link
Contributor Author

prpr19xx commented Feb 1, 2024

OK, it's an easy fix, but it breaks previously working code.
I note that the 0.82 release documentation didn't actually state what the default buffering mode was, nor does the current version say this has changed, but at least it now tells you what it is.

@msteveb
Copy link
Owner

msteveb commented Feb 2, 2024

The docs for aio buffering say:

Channels usually begin in full buffering mode, unless they identify
as a tty channel, in which case line buffering is used, and `stderr`
begins with no buffering.

And this is still true. With full buffering you can't rely on when the buffer is flushed without an explicit flush. If it worked before it was just "lucky" as a side effect of the implementation (probably that a switch from write to read caused a flush), but that is not part of the documented interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants