Add a termination validator hook

Explains why `aeronmd` never actually shut down
pull/6/head
Bradlee Speice 2019-10-06 18:17:28 -04:00
parent b548c867c8
commit 730252127b
1 changed files with 23 additions and 0 deletions

View File

@ -17,6 +17,10 @@ unsafe extern "C" fn termination_hook(_clientd: *mut c_void) {
RUNNING.store(false, Ordering::SeqCst);
}
unsafe extern "C" fn termination_validator(_state: *mut c_void, _buffer: *mut u8, _length: i32) -> bool {
true
}
fn main() {
let version = unsafe { CStr::from_ptr(aeron_version_full()) };
let _cmdline = clap::App::new("aeronmd")
@ -64,6 +68,25 @@ fn main() {
}
}
if init_success {
let term_validator = unsafe {
aeron_driver_context_set_driver_termination_validator(
context,
Some(termination_validator),
ptr::null_mut()
)
};
if term_validator < 0 {
let err_code = unsafe { aeron_errcode() };
let err_str = unsafe { CStr::from_ptr(aeron_errmsg()) }.to_str().unwrap();
eprintln!(
"ERROR: context set termination validator ({}), {}",
err_code, err_str
);
init_success = false
}
}
if init_success {
let driver_init = unsafe { aeron_driver_init(&mut driver, context) };
if driver_init < 0 {