diff --git a/examples/aeronmd.rs b/examples/aeronmd.rs index a7786b4..6909ff3 100644 --- a/examples/aeronmd.rs +++ b/examples/aeronmd.rs @@ -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 {