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

net: Conn.Close() does not error on double close on wasm #45423

Open
johanbrandhorst opened this issue Apr 7, 2021 · 1 comment
Open

net: Conn.Close() does not error on double close on wasm #45423

johanbrandhorst opened this issue Apr 7, 2021 · 1 comment

Comments

@johanbrandhorst
Copy link
Member

@johanbrandhorst johanbrandhorst commented Apr 7, 2021

Does this issue reproduce with the latest release?

Yes

What did you do?

Tried to write a test that checks whether a net.Conn is already closed by checking that calling Close returns an error and run it on wasm. See

if runtime.GOARCH == "wasm" {
t.Skip("conn.Close does not error as expected when called multiple times on WASM")
}
for the current workaround.

What did you expect to see?

An error suggesting that the connection has already been closed, as is consistent with all other architectures tested.

What did you see instead?

No error.

Discussion

I think the offending code is here:

go/src/net/net_fake.go

Lines 110 to 115 in 5d5f779

func (fd *netFD) Close() error {
fd.closedMu.Lock()
if fd.closed {
fd.closedMu.Unlock()
return nil
}

On unix platforms the behaviour is to return internal/poll.ErrNetClosing or internal/pool.ErrFileClosing:

func (fd *FD) Close() error {
if !fd.fdmu.increfAndClose() {
return errClosing(fd.isFile)
}

func errClosing(isFile bool) error {
if isFile {
return ErrFileClosing
}
return ErrNetClosing
}

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

Successfully merging a pull request may close this issue.

None yet
2 participants