Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AGENT] Avoid cleaning all exceptions #5267

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions agent/src/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ use public::proto::trident::Exception;
pub struct ExceptionHandler(Arc<AtomicU64>);

impl ExceptionHandler {
const AUTO_CLEAR_BITS: u64 = Exception::NpbNoGwArp as u64
| Exception::AnalyzerNoGwArp as u64
| Exception::NpbBpsThresholdExceeded as u64
| Exception::RxPpsThresholdExceeded as u64
| Exception::ProcessThresholdExceeded as u64
| Exception::ThreadThresholdExceeded as u64
| Exception::LogFileExceeded as u64
| Exception::ControllerSocketError as u64
| Exception::AnalyzerSocketError as u64
| Exception::NpbSocketError as u64;

pub fn set(&self, e: Exception) {
self.0.fetch_or(e as u64, Ordering::SeqCst);
}
Expand All @@ -34,7 +45,7 @@ impl ExceptionHandler {
}

pub fn take(&self) -> u64 {
self.0.swap(0, Ordering::SeqCst)
self.0.fetch_and(!Self::AUTO_CLEAR_BITS, Ordering::SeqCst)
}
}

Expand Down Expand Up @@ -71,6 +82,7 @@ mod tests {
assert_eq!(h.0.load(Ordering::Relaxed), expected);

assert_eq!(h.take(), expected);
assert_eq!(h.0.load(Ordering::Relaxed), 0);
expected &= !(ExceptionHandler::AUTO_CLEAR_BITS);
assert_eq!(h.0.load(Ordering::Relaxed), expected);
}
}