Skip to content

Avoid using buffer_unordered#518

Merged
tomusdrw merged 3 commits intomasterfrom
td-http
Nov 26, 2019
Merged

Avoid using buffer_unordered#518
tomusdrw merged 3 commits intomasterfrom
td-http

Conversation

@tomusdrw
Copy link
Copy Markdown
Contributor

...and rather spawn tasks directly on the executor.

This should fix issues with unresponsive server, while still not breaking the previous fix causing the server to not be closed properly when there were pending requests. Now we use Weak references and only try to upgrade them when we handle the request.

@tomusdrw tomusdrw requested a review from dvdplm November 15, 2019 12:25
Copy link
Copy Markdown
Contributor

@seunlanlege seunlanlege left a comment

Choose a reason for hiding this comment

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

looks sane, something's up with gitlab

Copy link
Copy Markdown
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

lgtm

Comment thread http/src/handler.rs
let metadata = self.jsonrpc_handler.extractor.read_metadata(&request);
let handler = match self.jsonrpc_handler.upgrade() {
Some(handler) => handler,
None => return RpcHandlerState::Writing(Response::closing()),
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.

Is returning a "500 Internal Error" here really the best? Could it be a "503 Service Unavailable" (with a Retry-After header even?), maybe Response::service_unavailable()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, makes sense. Will update.

Comment thread http/src/handler.rs
Comment thread http/src/lib.rs
.then(|_| Ok(()))
tokio::spawn(
http.serve_connection(socket, service)
.map_err(|e| error!("Error serving connection: {:?}", e))
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.

rustfmt is angry with you about this line. Maybe put the map_err(|e| { on the preceding line?

@tomusdrw
Copy link
Copy Markdown
Contributor Author

That one is returning an application/json content type, I need plain.

@tomusdrw
Copy link
Copy Markdown
Contributor Author

Merging, as @dvdplm reported no performance degradation.

@tomusdrw tomusdrw merged commit d661b0c into master Nov 26, 2019
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.

3 participants