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

rpc: fix defer in test #24490

Merged
merged 3 commits into from
Mar 11, 2022
Merged

rpc: fix defer in test #24490

merged 3 commits into from
Mar 11, 2022

Conversation

s7v7nislands
Copy link
Contributor

No description provided.

@s7v7nislands s7v7nislands requested review from fjl and holiman as code owners March 2, 2022 00:36
conn.(*net.TCPConn).CloseWrite()
// Now try to get the response.
buf := make([]byte, 2000)
n, err := conn.Read(buf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way to fix this would have been to just move the defer conn.Close() to here, like this:

         n, err := conn.Read(buf)
         conn.Close()
         if err != nil{ 
               ...

I don't really have an opinion. Your way works too. Any other opinions? cc @fjl

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'd prefer that too (moving the close after read).

I also think the defer in loop is not a big deal here. It's a unit test, and the loop has a constant number of iterations.

@holiman holiman added this to the 1.10.17 milestone Mar 9, 2022
@holiman
Copy link
Contributor

holiman commented Mar 9, 2022

quirky:

--- FAIL: TestClientWebsocketPing (0.00s)
    websocket_test.go:315: can't listen: listen tcp 127.0.0.1:0: socket: An operation was attempted on something that is not a socket.
--- FAIL: TestClientWebsocketSevered (0.00s)
    websocket_test.go:315: can't listen: listen tcp 127.0.0.1:0: socket: An operation was attempted on something that is not a socket.
--- FAIL: TestWebsocketLargeCall (0.00s)
panic: httptest: failed to listen on a port: listen tcp6 [::1]:0: socket: An operation was attempted on something that is not a socket. [recovered]
	panic: httptest: failed to listen on a port: listen tcp6 [::1]:0: socket: An operation was attempted on something that is not a socket.

@fjl
Copy link
Contributor

fjl commented Mar 9, 2022

Yeah, very interesting behavior there. Looks like a Go runtime issue? Maybe CloseWrite + Close leads to fd confusion in runtime.

@holiman
Copy link
Contributor

holiman commented Mar 10, 2022

Yeah, but still, the change concerns TestServerShortLivedConn, not any of the tests that failed.

@holiman
Copy link
Contributor

holiman commented Mar 10, 2022

https://support.microsoft.com/en-us/topic/7b064553-5332-b525-2dd4-4e123f9f7f23

This behavior may occur if the WinSocks library or the TCP/IP stack are corrupted.

Yikes :)

@holiman
Copy link
Contributor

holiman commented Mar 10, 2022

I've restarted the build, maybe it was just a random error

@fjl fjl merged commit 496f05c into ethereum:master Mar 11, 2022
sidhujag pushed a commit to syscoin/go-ethereum that referenced this pull request Mar 11, 2022
Co-authored-by: Felix Lange <fjl@twurst.com>
@s7v7nislands s7v7nislands deleted the fix_defer branch May 4, 2022 02:11
JacekGlen pushed a commit to JacekGlen/go-ethereum that referenced this pull request May 26, 2022
Co-authored-by: Felix Lange <fjl@twurst.com>
maoueh pushed a commit to streamingfast/go-ethereum that referenced this pull request Sep 30, 2022
Co-authored-by: Felix Lange <fjl@twurst.com>
cp-wjhan pushed a commit to cp-yoonjin/go-wemix that referenced this pull request Nov 16, 2022
Co-authored-by: Felix Lange <fjl@twurst.com>
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

Successfully merging this pull request may close these issues.

3 participants