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

Conn.Close should prevent all writes after writing the close frame #213

Closed
zhangyoufu opened this issue Mar 15, 2020 · 4 comments
Closed
Assignees
Milestone

Comments

@zhangyoufu
Copy link

From RFC6455 §1.4:

After sending a control frame indicating the connection should be closed, a peer does not send any further data

Current implementation does not obey this rule.

@nhooyr
Copy link
Contributor

nhooyr commented Mar 15, 2020

How does it not obey this rule?

@nhooyr
Copy link
Contributor

nhooyr commented Mar 15, 2020

Once Close is called, nothing else can ever be written.

@zhangyoufu
Copy link
Author

Once Close is called, nothing else can ever be written.

It takes a long time until defer conn.close(nil) happen. If you look at on-wire packets, there can be many data frames being sent after the close frame.

@nhooyr
Copy link
Contributor

nhooyr commented Mar 15, 2020

Fair enough, it doesn't explicitly prevent you from writing any additional data but once the peer receives a close frame, it stops reading from the connection so writing any additional garbage data isn't an issue. The RFC states that so that the peer knows not to read anything after a close.

Making all writes after a close frame fail should be really easy anyway so lets take care of this.

@nhooyr nhooyr self-assigned this Mar 15, 2020
@nhooyr nhooyr changed the title Conn.Close violates RFC6455 Conn.Close should prevent all writes after writing the close frame Mar 15, 2020
@nhooyr nhooyr added this to the v1.8.5 milestone Apr 13, 2020
@nhooyr nhooyr closed this as completed in d34c89a Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants