perf(server): try to read from socket at keep-alive
In most situations, this should reduce the number of task wake ups by 1 per request, which can help if reading the request was small.
This commit is contained in:
@@ -228,6 +228,16 @@ where I: AsyncRead + AsyncWrite,
|
||||
}
|
||||
|
||||
if !self.io.is_read_blocked() {
|
||||
if self.io.read_buf().is_empty() {
|
||||
match self.io.read_from_io() {
|
||||
Ok(Async::Ready(_)) => (),
|
||||
Ok(Async::NotReady) => return,
|
||||
Err(e) => {
|
||||
trace!("maybe_notify read_from_io error: {}", e);
|
||||
self.state.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(ref task) = self.state.read_task {
|
||||
task.notify();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user