-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
rpc: fix defer in test #24490
Conversation
rpc/server_test.go
Outdated
conn.(*net.TCPConn).CloseWrite() | ||
// Now try to get the response. | ||
buf := make([]byte, 2000) | ||
n, err := conn.Read(buf) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
quirky:
|
Yeah, very interesting behavior there. Looks like a Go runtime issue? Maybe CloseWrite + Close leads to fd confusion in runtime. |
Yeah, but still, the change concerns |
https://support.microsoft.com/en-us/topic/7b064553-5332-b525-2dd4-4e123f9f7f23
Yikes :) |
I've restarted the build, maybe it was just a random error |
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
No description provided.