-
Notifications
You must be signed in to change notification settings - Fork 14
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
timing in 23connect.t #7
Comments
This is the most likely issue indeed. Looking at the history of this test script, I've been fiddling with Among the things I'd try:
Since you have a setup where this test seems to reliably fail, could you try some of those? |
It's easy getting the test to pass by appending a "sleep 1;" after getting the client_socket (line 66). I'm not sure, though, if this is the right approach and whether the bug is in the test (e.g. client has to wait) or in HTTP-Proxy itself (e.g. connect to server first, then send "200 OK" to client). I'll have a further look at it, but reading the RFCs and getting myself familiar with the HTTP-Proxy code will take a while. |
It's an error in the test. The LWP-UserAgent works in non-blocking mode, so when we take the 'client_socket' and read via 'getline' while the server isn't ready yet, the read doesn't block and we get an EOF immediately. You can trigger the problem on a system where it normally doesn't occur by inserting a 'sleep 2;' before sending the server banner. Adding something like
after line 65 should fix it. |
Quoting the report from e477 in #7: The LWP-UserAgent works in non-blocking mode, so when we take the 'client_socket' and read via 'getline' while the server isn't ready yet, the read doesn't block and we get an EOF immediately. You can trigger the problem on a system where it normally doesn't occur by inserting a 'sleep 2;' before sending the server banner.
Thanks, I applied the fix (and removed all |
This does fix the issue for me. |
Thanks for the feedback. I'll make a release soon. |
Sorry. I wanted to write that it does NOT fix the issue for me. I still get random failures. |
Oh. Then I have some questions for you:
|
This is Fedora Rawhide (Fedora 23) with perl 5.22.0. I cannot reproduce the failure on Fedora 22 (perl 5.20.2). Here's what it looks like when it passes on Fedora 22:
I tried to get it to fail again with logging enabled in Rawhide... and it succeeded. :/ I'm guessing this is a timing issue. |
I'm able to reproduce this issue on Debian, and it looks like the problem here is Net::HTTP (as used by LWP::Protocol::http) buffering. I've got "strace -e read,write" output from a failing case which shows the LWP::UserAgent client getting the content in the same read call with the header fields. Later explicit read() calls on the socket then get EOF, resulting in empty data. With a diagnostic like
I can't see an interface to get the buffered data from LWP::UserAgent, so this looks to me like a bug in LWP::UserAgent HTTP CONNECT support? |
23connect.t exposes an interesting timing issue. The proxy accepts the CONNECT and the 'is' in line 69 passes, but then reading from the socket in line 76 returns 'undef' and the test fails. However, the test passes when I try to monitor its behaviour with tcpdump.
With logging enabled:
With logging enabled and tcpdump running in the background:
Could this be the result of the client trying to read from the proxy before the proxy has connected to or read from the server?
The text was updated successfully, but these errors were encountered: