bugfix, outbound/failover: fail-timeout should cover the connect time
This commit is contained in:
@@ -120,29 +120,46 @@ impl OutboundDatagramHandler for Handler {
|
||||
let a = &self.actors[i];
|
||||
|
||||
debug!(
|
||||
"failover handles udp [{}] to [{}]",
|
||||
"[{}] handles [{}:{}] to [{}]",
|
||||
a.tag(),
|
||||
sess.network,
|
||||
sess.destination,
|
||||
a.tag()
|
||||
);
|
||||
|
||||
match timeout(
|
||||
Duration::from_secs(self.fail_timeout as u64),
|
||||
a.datagram()?.handle(
|
||||
sess,
|
||||
connect_datagram_outbound(sess, self.dns_client.clone(), a).await?,
|
||||
),
|
||||
)
|
||||
.await
|
||||
{
|
||||
// return before timeout
|
||||
let try_outbound = async move {
|
||||
a.datagram()?
|
||||
.handle(
|
||||
sess,
|
||||
connect_datagram_outbound(sess, self.dns_client.clone(), a).await?,
|
||||
)
|
||||
.await
|
||||
};
|
||||
|
||||
match timeout(Duration::from_secs(self.fail_timeout as u64), try_outbound).await {
|
||||
Ok(t) => match t {
|
||||
// return ok
|
||||
Ok(v) => return Ok(v),
|
||||
// return err
|
||||
Err(_) => continue,
|
||||
Err(e) => {
|
||||
trace!(
|
||||
"[{}] failed to handle [{}:{}]: {}",
|
||||
a.tag(),
|
||||
sess.network,
|
||||
sess.destination,
|
||||
e,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
},
|
||||
// after timeout
|
||||
Err(_) => continue,
|
||||
Err(e) => {
|
||||
trace!(
|
||||
"[{}] failed to handle [{}:{}]: {}",
|
||||
a.tag(),
|
||||
sess.network,
|
||||
sess.destination,
|
||||
e,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -159,32 +159,23 @@ impl OutboundStreamHandler for Handler {
|
||||
let a = &self.actors[actor_idx];
|
||||
|
||||
debug!(
|
||||
"failover handles tcp [{}] to [{}]",
|
||||
"[{}] handles [{}:{}] to [{}]",
|
||||
a.tag(),
|
||||
sess.network,
|
||||
sess.destination,
|
||||
a.tag()
|
||||
);
|
||||
|
||||
match timeout(
|
||||
Duration::from_secs(self.fail_timeout as u64),
|
||||
a.stream()?.handle(
|
||||
sess,
|
||||
match connect_stream_outbound(sess, self.dns_client.clone(), a).await {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
trace!(
|
||||
"[{}] failed to handle [{}]: {}",
|
||||
a.tag(),
|
||||
sess.destination,
|
||||
e,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
.await
|
||||
{
|
||||
// return before timeout
|
||||
let try_outbound = async move {
|
||||
a.stream()?
|
||||
.handle(
|
||||
sess,
|
||||
connect_stream_outbound(sess, self.dns_client.clone(), a).await?,
|
||||
)
|
||||
.await
|
||||
};
|
||||
|
||||
match timeout(Duration::from_secs(self.fail_timeout as u64), try_outbound).await {
|
||||
Ok(t) => match t {
|
||||
Ok(v) => {
|
||||
// Only cache for fallback actors.
|
||||
@@ -199,8 +190,9 @@ impl OutboundStreamHandler for Handler {
|
||||
}
|
||||
Err(e) => {
|
||||
trace!(
|
||||
"[{}] failed to handle [{}]: {}",
|
||||
"[{}] failed to handle [{}:{}]: {}",
|
||||
a.tag(),
|
||||
sess.network,
|
||||
sess.destination,
|
||||
e,
|
||||
);
|
||||
@@ -209,8 +201,9 @@ impl OutboundStreamHandler for Handler {
|
||||
},
|
||||
Err(e) => {
|
||||
trace!(
|
||||
"[{}] failed to handle [{}]: {}",
|
||||
"[{}] failed to handle [{}:{}]: {}",
|
||||
a.tag(),
|
||||
sess.network,
|
||||
sess.destination,
|
||||
e,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user