Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReplace rust-websocket with ws-rs in the debugger server. #13258
Conversation
highfive
commented
Sep 13, 2016
|
Heads up! This PR modifies the following files:
|
cf48f2d
to
2c2819e
|
|
|
Review ping! |
|
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.
This comment has been minimized.
metajack
Sep 27, 2016
Contributor
nit: this would be slightly more clear as debugger::shutdown_server(chan) I think.
This comment has been minimized.
This comment has been minimized.
|
|
||
| impl Handler for Connection { | ||
| fn on_open(&mut self, _: Handshake) -> ws::Result<()> { | ||
| println!("Connection opened."); |
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| fn on_close(&mut self, _: CloseCode, _: &str) { | ||
| println!("Connection closed."); |
This comment has been minimized.
This comment has been minimized.
| panic!("Unexpected message type."); | ||
| } | ||
| pub fn start_server(port: u16) -> Sender { | ||
| println!("Starting server."); |
This comment has been minimized.
This comment has been minimized.
| Connection { sender: sender } | ||
| }).unwrap(); | ||
| let sender = socket.broadcaster(); | ||
| spawn_named("debugger-websocket".to_owned(), move || { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
| } | ||
|
|
||
| pub fn shutdown_server(sender: &Sender) { | ||
| println!("Shutting down server."); |
This comment has been minimized.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
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.
|
@bors-servo r+ |
|
|
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 -->
|
|
|
|
|
|
Superseded by #14110. |
ejpbruel commentedSep 13, 2016
•
edited
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 -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is