1
0
mirror of https://github.com/bspeice/aeron-rs synced 2024-12-22 05:48:10 -05:00

Add a termination validator hook

Explains why `aeronmd` never actually shut down
This commit is contained in:
Bradlee Speice 2019-10-06 18:17:28 -04:00
parent b548c867c8
commit 730252127b

View File

@ -17,6 +17,10 @@ unsafe extern "C" fn termination_hook(_clientd: *mut c_void) {
RUNNING.store(false, Ordering::SeqCst); RUNNING.store(false, Ordering::SeqCst);
} }
unsafe extern "C" fn termination_validator(_state: *mut c_void, _buffer: *mut u8, _length: i32) -> bool {
true
}
fn main() { fn main() {
let version = unsafe { CStr::from_ptr(aeron_version_full()) }; let version = unsafe { CStr::from_ptr(aeron_version_full()) };
let _cmdline = clap::App::new("aeronmd") 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 { if init_success {
let driver_init = unsafe { aeron_driver_init(&mut driver, context) }; let driver_init = unsafe { aeron_driver_init(&mut driver, context) };
if driver_init < 0 { if driver_init < 0 {