Skip to content

Commit

Permalink
stop process on accept failure (endpoint is closed)
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-maron committed Mar 5, 2024
1 parent a3673ac commit f64f749
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
6 changes: 3 additions & 3 deletions broker/src/tasks/broker_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use proto::{
crypto::signature::SignatureScheme,
};
use tokio::spawn;
use tracing::warn;
use tracing::error;
// TODO: change connection to be named struct instead of tuple for readability purposes

use crate::Inner;
Expand All @@ -32,8 +32,8 @@ impl<
let unfinalized_connection = match listener.accept().await {
Ok(connection) => connection,
Err(err) => {
warn!("failed to accept connection: {}", err);
continue;
error!("failed to accept connection: {}", err);
return;
}
};

Expand Down
6 changes: 3 additions & 3 deletions broker/src/tasks/user_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use proto::{
crypto::signature::SignatureScheme,
};
use tokio::spawn;
use tracing::warn;
use tracing::error;

use crate::Inner;

Expand All @@ -31,8 +31,8 @@ impl<
let unfinalized_connection = match listener.accept().await {
Ok(connection) => connection,
Err(err) => {
warn!("failed to accept connection: {}", err);
continue;
error!("failed to accept connection: {}", err);
return;
}
};

Expand Down
13 changes: 5 additions & 8 deletions marshal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use proto::{
DiscoveryClientType,
};
use tokio::spawn;
use tracing::warn;

/// The `Marshal's` configuration (with a Builder), to help with usability.
/// We need this to construct a `Marshal`
Expand Down Expand Up @@ -105,13 +104,11 @@ impl<Scheme: SignatureScheme, UserProtocol: Protocol> Marshal<Scheme, UserProtoc
//
// TODO: figure out when an endpoint closes, should I be looping on it? What are the criteria
// for closing? It would error but what does that actually _mean_? Is it recoverable?
let unfinalized_connection = match self.listener.accept().await {
Ok(connection) => connection,
Err(err) => {
warn!("failed to accept connection: {}", err);
continue;
}
};
let unfinalized_connection = bail!(
self.listener.accept().await,
Connection,
"failed to accept connection"
);

// Create a task to handle the connection
let discovery_client = self.discovery_client.clone();
Expand Down
2 changes: 1 addition & 1 deletion proto/src/connection/auth/marshal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl<Scheme: SignatureScheme, UserProtocol: Protocol> MarshalAuth<Scheme, UserPr
let permit = match discovery_client
.issue_permit(
&broker_with_least_connections,
Duration::from_secs(5),
Duration::from_secs(30),
auth_message.public_key,
)
.await
Expand Down

0 comments on commit f64f749

Please sign in to comment.