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

Replace rust-websocket with ws-rs in the debugger server. #13258

Closed
wants to merge 1 commit into from

Conversation

@ejpbruel
Copy link
Contributor

ejpbruel commented Sep 13, 2016

I'm running into several issues with the rust-websocket library. In particular, rust-websocket doesn't seem to make it possible to shut down the websocket server or close individual connections from another thread.

This pull request replaces the rust-websocket library with the ws-rs library. This websocket library is based on mio, and its functionality seems to be closer to what we need. In particular, ws-rs allows shutting down the server from another thread, and handles connection management automatically.

I have updated this pull request to include the changes from my two earlier pull requests, whose changes this pull request subsumes. In particular, one of the earlier pull requests added a way for the constellation to shut down the debugger server, by sending it a ShutdownServer message.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because this is a prototype

This change is Reviewable

@highfive
Copy link

highfive commented Sep 13, 2016

Heads up! This PR modifies the following files:

  • @asajeffrey: components/constellation/Cargo.toml, components/constellation/constellation.rs, components/constellation/lib.rs
  • @fitzgen: components/debugger/Cargo.toml, components/debugger/lib.rs
@jdm jdm added the S-needs-rebase label Sep 13, 2016
@ejpbruel ejpbruel force-pushed the ejpbruel:ws branch 3 times, most recently from cf48f2d to 2c2819e Sep 19, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Sep 23, 2016

The latest upstream changes (presumably #13393) made this pull request unmergeable. Please resolve the merge conflicts.

@ejpbruel ejpbruel force-pushed the ejpbruel:ws branch from 2c2819e to 1487eb5 Sep 27, 2016
@ejpbruel
Copy link
Contributor Author

ejpbruel commented Sep 27, 2016

Review ping!

Copy link
Contributor

metajack left a comment

This looks great. Main thing to address is bitflags having multiple versions.

@@ -1053,6 +1061,10 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
warn!("Exit resource thread failed ({})", e);
}

if let Some(ref chan) = self.debugger_chan {
shutdown_server(chan);

This comment has been minimized.

@metajack

metajack Sep 27, 2016

Contributor

nit: this would be slightly more clear as debugger::shutdown_server(chan) I think.

This comment has been minimized.

@ejpbruel

ejpbruel Sep 28, 2016

Author Contributor

Agreed


impl Handler for Connection {
fn on_open(&mut self, _: Handshake) -> ws::Result<()> {
println!("Connection opened.");

This comment has been minimized.

@metajack

metajack Sep 27, 2016

Contributor

These should probably be debug! or removed.

}

fn on_close(&mut self, _: CloseCode, _: &str) {
println!("Connection closed.");

This comment has been minimized.

@metajack

metajack Sep 27, 2016

Contributor

debug! or remove

panic!("Unexpected message type.");
}
pub fn start_server(port: u16) -> Sender {
println!("Starting server.");

This comment has been minimized.

@metajack

metajack Sep 27, 2016

Contributor

debug! or remove

Connection { sender: sender }
}).unwrap();
let sender = socket.broadcaster();
spawn_named("debugger-websocket".to_owned(), move || {

This comment has been minimized.

@metajack

metajack Sep 27, 2016

Contributor

How does this thread die?

This comment has been minimized.

@ejpbruel

ejpbruel Sep 28, 2016

Author Contributor

It dies when the main debugger thread receives a ShutdownServer message, breaks out of its main message loop, and calls sender.shutdown().unwrap(). This will break the websocket server out of its listen loop, allowing the thread to clean itself up.

This comment has been minimized.

@metajack

metajack Sep 30, 2016

Contributor

I meant the thread that is calling listen(). It seems like it will sit forever.

This comment has been minimized.

@metajack

metajack Sep 30, 2016

Contributor

Discussed in IRC and resolved.

}

pub fn shutdown_server(sender: &Sender) {
println!("Shutting down server.");

This comment has been minimized.

@metajack

metajack Sep 27, 2016

Contributor

debug! or remove

@@ -183,6 +183,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "bitflags"
version = "0.4.0"

This comment has been minimized.

@metajack

metajack Sep 27, 2016

Contributor

Can we avoid multiple versions of bitflags?

This comment has been minimized.

@ejpbruel

ejpbruel Sep 28, 2016

Author Contributor

I'm not sure how to accomplish this. It looks like the ws library pulls in a different version of the bitflag library than servo itself. How would I go about resolving this?

This comment has been minimized.

@nox

nox Sep 28, 2016

Member

It needs nix-rust/nix#431. I don't think it is a problem to include 2 versions of bitflags given how small that crate is. It was already an exception in the past anyway.

This comment has been minimized.

@metajack

metajack Sep 30, 2016

Contributor

Ok. I'm fine with extra bitflags then. Can we file a bug upstream to update it at least?

This comment has been minimized.

@nox

nox Sep 30, 2016

Member

You mean the nix PR that I filed and mentioned in the comment you just replied to? :)

@@ -156,6 +156,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "bitflags"
version = "0.4.0"

This comment has been minimized.

@metajack

metajack Sep 27, 2016

Contributor

Dupe bitflags.

@@ -4,7 +4,7 @@ skip-check-licenses = false

[ignore]
# Ignored packages with duplicated versions
packages = ["lazy_static"]
packages = ["bitflags", "lazy_static"]

This comment has been minimized.

@metajack

metajack Sep 27, 2016

Contributor

There's no reasoning anywhere for why a dupe bitflags is required. I think that should be explained somewhere or a bug filed and referenced before we allow this.

@nox
Copy link
Member

nox commented Sep 27, 2016

@metajack
Copy link
Contributor

metajack commented Sep 30, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Sep 30, 2016

📌 Commit 9083667 has been approved by metajack

@bors-servo
Copy link
Contributor

bors-servo commented Sep 30, 2016

Testing commit 9083667 with merge fa760d9...

bors-servo added a commit that referenced this pull request Sep 30, 2016
Replace rust-websocket with ws-rs in the debugger server.

<!-- Please describe your changes on the following line: -->

I'm running into several issues with the rust-websocket library. In particular, rust-websocket doesn't seem to make it possible to shut down the websocket server or close individual connections from another thread.

This pull request replaces the rust-websocket library with the ws-rs library. This websocket library is based on mio, and its functionality seems to be closer to what we need. In particular, ws-rs allows shutting down the server from another thread, and handles connection management automatically.

I have updated this pull request to include the changes from my two earlier pull requests, whose changes this pull request subsumes. In particular, one of the earlier pull requests added a way for the constellation to shut down the debugger server, by sending it a ShutdownServer message.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because this is a prototype

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

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

bors-servo commented Sep 30, 2016

💔 Test failed - linux-dev

@jdm
Copy link
Member

jdm commented Sep 30, 2016

error: failed to parse lock file at: /home/servo/buildbot/slave/linux-dev/build/ports/cef/Cargo.lock
@bors-servo
Copy link
Contributor

bors-servo commented Oct 18, 2016

The latest upstream changes (presumably #13711) made this pull request unmergeable. Please resolve the merge conflicts.

@nox
Copy link
Member

nox commented Nov 7, 2016

Superseded by #14110.

@nox nox closed this Nov 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.