Skip to content

Commit

Permalink
print warning if send could not be spawn; cancel token if daemon errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mkolopanis committed Mar 15, 2024
1 parent 3957ea2 commit 70806d0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions cfdp-daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,12 @@ impl<T: FileStore + Send + Sync + 'static> Daemon<T> {
// it has initiated but there is no active transaction.
warn!("{error}")
}
Err(err) => return Err(err),
Err(err) => {
if !self.terminate.load(Ordering::Relaxed) {
self.terminate.store(true, Ordering::Relaxed);
}
return Err(err),

Check failure on line 597 in cfdp-daemon/src/lib.rs

View workflow job for this annotation

GitHub Actions / lint (clippy, stable)

expected one of `.`, `;`, `?`, `}`, or an operator, found `,`
}
},
None => {
if !self.terminate.load(Ordering::Relaxed) {
Expand All @@ -603,12 +608,23 @@ impl<T: FileStore + Send + Sync + 'static> Daemon<T> {
primitive = self.primitive_rx.recv() => match primitive {
Some(primitive) => match self.process_primitive(primitive).await{
Ok(_) => {},
Err(error & DaemonError::SpawnSend(_)) => {

Check failure on line 611 in cfdp-daemon/src/lib.rs

View workflow job for this annotation

GitHub Actions / lint (clippy, stable)

expected one of `)`, `,`, `@`, or `|`, found `&`

Check failure on line 611 in cfdp-daemon/src/lib.rs

View workflow job for this annotation

GitHub Actions / lint (clippy, stable)

this pattern has 2 fields, but the corresponding tuple variant has 1 field
// Unable to spawn a send transaction.
// There are lots of reasons this cound happen.
// Mostly if a user asked for a file that doesn't exist.
warn!("{error}")
},
Err(error @ DaemonError::TransactionCommuncation(_, _)) => {
// This occcurs most likely if a user is attempting to
// interact with a transaction that is already finished.
warn!("{error}")
}
Err(err) => return Err(err),
Err(err) => {
if !self.terminate.load(Ordering::Relaxed) {
self.terminate.store(true, Ordering::Relaxed);
}
return Err(err),

Check failure on line 626 in cfdp-daemon/src/lib.rs

View workflow job for this annotation

GitHub Actions / lint (clippy, stable)

expected one of `.`, `;`, `?`, `}`, or an operator, found `,`
}
},
None => {
info!("User triggered daemon shutdown.");
Expand Down

0 comments on commit 70806d0

Please sign in to comment.