fix empty h1 messages queue handling

This commit is contained in:
Nikolay Kim 2020-04-04 13:26:44 +06:00
parent 4fec1520d2
commit 94790da9fd

View file

@ -348,7 +348,7 @@ where
CallProcess::Io => {
// service call queue is empty, we can process next request
if this.inner.poll_write(cx)? == PollWrite::AllowNext {
match this.inner.process_messages()? {
match this.inner.process_messages(CallProcess::Io)? {
CallProcess::Next(st) => {
this = self.as_mut().project();
this.call.set(st);
@ -358,7 +358,8 @@ where
this.upgrade.set(Some(fut));
return self.poll(cx);
}
CallProcess::Io | CallProcess::Pending => (),
CallProcess::Io => (),
CallProcess::Pending => unreachable!(),
}
}
false
@ -837,13 +838,16 @@ where
let (res, body) = res.replace_body(());
if self.send_response(res, body)? {
// response does not have body, so we can process next request
self.process_messages()
self.process_messages(CallProcess::Next(CallState::Io))
} else {
Ok(CallProcess::Next(CallState::Io))
}
}
fn process_messages(&mut self) -> Result<CallProcess<S, X, U>, DispatchError> {
fn process_messages(
&mut self,
io: CallProcess<S, X, U>,
) -> Result<CallProcess<S, X, U>, DispatchError> {
while let Some(msg) = self.messages.pop_front() {
return match msg {
DispatcherMessage::Request(req) => {
@ -874,12 +878,12 @@ where
// response does not have body, so we can process next request
continue;
} else {
return Ok(CallProcess::Io);
return Ok(io);
}
}
};
}
Ok(CallProcess::Io)
Ok(io)
}
}