Skip to content

Commit

Permalink
fix wouldblock, more debug
Browse files Browse the repository at this point in the history
Signed-off-by: Eloi DEMOLIS <[email protected]>
  • Loading branch information
Wonshtrum committed Oct 20, 2023
1 parent 7b090a0 commit f22cf0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 deletions lib/src/protocol/kawa_h1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,13 @@ impl<Front: SocketHandler, L: ListenerHandler + L7ListenerHandler> Http<Front, L
);
return SessionResult::Close;
}
SocketResult::WouldBlock | SocketResult::Closed => {
SocketResult::Closed => {
warn!("=====back_readable:{:?}/{}", socket_state, self.response_stream.is_initial());
self.backend_readiness.event.remove(Ready::READABLE);
}
SocketResult::WouldBlock => {
self.backend_readiness.event.remove(Ready::READABLE);
}
SocketResult::Continue => {}
}

Expand Down Expand Up @@ -1251,6 +1254,9 @@ impl<Front: SocketHandler, L: ListenerHandler + L7ListenerHandler> Http<Front, L

self.backend_readiness.interest = Ready::WRITABLE | Ready::HUP | Ready::ERROR;
self.backend_connection_status = BackendConnectionStatus::Connecting(Instant::now());
if !self.backend_readiness.event.is_empty() {
warn!("======connect_with_event:{:?}", self.backend_readiness);
}

match old_backend_token {
Some(backend_token) => {
Expand Down Expand Up @@ -1446,8 +1452,9 @@ impl<Front: SocketHandler, L: ListenerHandler + L7ListenerHandler> Http<Front, L
if self.backend_readiness.event.is_hup() && !self.test_backend_socket() {
//retry connecting the backend
error!(
"{} error connecting to backend, trying again",
self.log_context()
"{} error connecting to backend, trying again {}",
self.log_context(),
self.connection_attempts
);

self.connection_attempts += 1;
Expand Down
5 changes: 4 additions & 1 deletion lib/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ impl SocketHandler for FrontRustls {
while !self.session.wants_read() {
match self.session.reader().read(&mut buf[size..]) {
Ok(0) => break,
Ok(sz) => size += sz,
Ok(sz) => {
size += sz;
can_read = false;
}
Err(e) => match e.kind() {
ErrorKind::WouldBlock => {
break;
Expand Down

0 comments on commit f22cf0a

Please sign in to comment.