Skip to content

stop client websocket close echoing server close - #10382

Merged
bors-servo merged 1 commit into
servo:masterfrom
bobthekingofegypt:fix-websocket-close
Jun 10, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
bobthekingofegypt:fix-websocket-close

Conversation

@bobthekingofegypt

Copy link
Copy Markdown
Contributor

Client initiated close requests should send a close message to the
server that the server will echo back to complete the process. Servo
should not then echo the servers close request back again to the server,
this guard stops servo from echoing a server close request if the
process was initiated by the client.

Tracked in #9803 (comment)


This change is Reviewable

@highfive

highfive commented Apr 3, 2016

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @KiChjang: components/net/websocket_loader.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 3, 2016
@highfive

highfive commented Apr 3, 2016

Copy link
Copy Markdown

warning Warning warning

  • These commits modify net code, but no tests are modified. Please consider adding a test!

Comment thread components/net/websocket_loader.rs Outdated
Type::Pong => continue,
Type::Close => {
ws_sender_incoming.lock().unwrap().send_message(&message).unwrap();
if client_initiated_close_incoming.load(Ordering::SeqCst) == false {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: if !client_initiated_close_incoming.load(Ordering::SeqCst) {

@metajack

metajack commented Apr 4, 2016

Copy link
Copy Markdown
Collaborator

r=me with @KiChjang's comment addressed


Review status: 0 of 1 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from Reviewable

@metajack

metajack commented Apr 4, 2016

Copy link
Copy Markdown
Collaborator

Reviewed 1 of 1 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from Reviewable

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 4, 2016
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Apr 4, 2016
@bobthekingofegypt

Copy link
Copy Markdown
Contributor Author

@KiChjang's comment addressed.

@metajack

metajack commented Apr 4, 2016

Copy link
Copy Markdown
Collaborator

@bors-servo r+


Reviewed 1 of 1 files at r2.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit cbfc36d has been approved by metajack

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 4, 2016
@metajack

metajack commented Apr 4, 2016

Copy link
Copy Markdown
Collaborator

@bors-servo r-

Please squash and we'll get this merged.

+S-needs-squash


Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@metajack metajack added the S-needs-squash Some (or all) of the commits in the PR should be combined. label Apr 4, 2016
@jdm jdm removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 4, 2016
@bobthekingofegypt

Copy link
Copy Markdown
Contributor Author

Sorry, I'll need to add the guard around https://github.com/bobthekingofegypt/servo/blob/fix-websocket-close/components/net/websocket_loader.rs#L160 as well. As it's still possible to send two close messages. Will get it done tomorrow.

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 10, 2016
@bobthekingofegypt

Copy link
Copy Markdown
Contributor Author

Sorry for the delay, I added the check around both incoming and outgoing. If it's ok, I'll squash all the commits.

@jdm jdm removed the S-needs-squash Some (or all) of the commits in the PR should be combined. label Apr 13, 2016
@metajack

Copy link
Copy Markdown
Collaborator

Looks good, aside from the comment I left. You can go ahead and squash it at the same time you address that.


Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


components/net/websocket_loader.rs, line 129 [r3] (raw file):
If we weren't waiting for the close to come in, we now set that we are. When we aren't waiting for a close, getting a close needs a ack. By sending this ack, we should not be getting an ack to our ack, nor did we send a client intiated close. So I'm not sure why you are toggling the bool in this case.


Comments from Reviewable

@perlun

perlun commented Apr 22, 2016

Copy link
Copy Markdown
Contributor

@bobthekingofegypt - any progress on this one?

@bobthekingofegypt

Copy link
Copy Markdown
Contributor Author

I can't really use computers at the moment due to an issue with my eye. So I can't really deal with this right now. I hope to be back to normal in a few weeks.

In response to your comment @metajack the reason that the boolean is checked and updated on both incoming and outgoing threads is due to the current threading.
From memory without checking anything it is to do with the websocket server initiating a close and the user script on servo side calling close at the same time, happens a lot on the test cases.
Whatever happens you only want to send one close whether it is an initiator or an echo, the boolean check and update on both means only one close with ever be sent regardless of the order the threads are executed.

I can write up a better explanation when I'm back but I'm just rushing this comment for now. If someone else wants to wrap this up feel free.

@bobthekingofegypt

Copy link
Copy Markdown
Contributor Author

components/net/websocket_loader.rs, line 129 [r3] (raw file):
Sorry, I think I misunderstood this when I replied in the PR. I'm still not sure I fully understand. I think I may have confused things by naming the variable initiated_close rather than something like sent_close.
I flip the guard here as well as down below because I only want to send a close once, regardless of whether it is an echo or an instigator. If I don't flip the guard here then a JS call to close the websocket can still trigger another close event through line 155 as the state on dom/websocket side is not yet marked as closed or closing.


Comments from Reviewable

@jdm

jdm commented Jun 8, 2016

Copy link
Copy Markdown
Member

The code and explanation makes sense to me. @bobthekingofegypt if you squash the commits, I'll merge it :)

@jdm jdm unassigned metajack Jun 8, 2016
@jdm jdm self-assigned this Jun 8, 2016
@jdm jdm added S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jun 8, 2016
@jdm jdm unassigned metajack Jun 8, 2016
@metajack

metajack commented Jun 8, 2016

Copy link
Copy Markdown
Collaborator

I'm not sure how I forgot to comment here. I could have sworn I wrote out an r=me.

In any case, I apologize for the delay and I agree with jdm.

Need to make sure close is only sent to the server once, either from a
client initiation or from a server echo.  This adds the sent check to
both incoming and outgoing threads.
@highfive

Copy link
Copy Markdown

New code was committed to pull request.

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 10, 2016
@jdm

jdm commented Jun 10, 2016

Copy link
Copy Markdown
Member

@bors-servo: r=metajack

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 27b4ac6 has been approved by metajack

@highfive highfive assigned metajack and unassigned jdm Jun 10, 2016
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Jun 10, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 27b4ac6 with merge 96f3404...

bors-servo pushed a commit that referenced this pull request Jun 10, 2016
stop client websocket close echoing server close

Client initiated close requests should send a close message to the
server that the server will echo back to complete the process.  Servo
should not then echo the servers close request back again to the server,
this guard stops servo from echoing a server close request if the
process was initiated by the client.

Tracked in #9803 (comment)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10382)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows

@bors-servo
bors-servo merged commit 27b4ac6 into servo:master Jun 10, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 10, 2016
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.

7 participants