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

handle deallocation request in native_resolve_cb #13

Merged
merged 1 commit into from
Jan 31, 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
9 changes: 9 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,15 @@ pub(crate) unsafe extern "C" fn native_resolve_cb<C: ClientContext>(
res: *mut *mut addrinfo,
opaque: *mut c_void,
) -> i32 {
if node.is_null() {
// If `node`` is `NULL`, we expect `service` and `hints` to also be
// `NULL`, and altogether this indicates a request to free `res`.
assert!(service.is_null());
assert!(hints.is_null());
unsafe { libc::freeaddrinfo(*res) }
return 0; // NOTE: this return code is ignored by librdkafka in this code path
}

// Convert host and port to Rust strings.
let host = match CStr::from_ptr(node).to_str() {
Ok(host) => host.into(),
Expand Down
Loading