Skip to content

Commit

Permalink
do not use NativeClient
Browse files Browse the repository at this point in the history
Signed-off-by: Runji Wang <[email protected]>
  • Loading branch information
wangrunji0408 committed Mar 22, 2024
1 parent 3039115 commit 4a8b518
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions madsim-rdkafka/src/std/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,23 @@ impl<C: ClientContext> Client<C> {
partition: i32,
timeout: T,
) -> KafkaResult<(i64, i64)> {
// XXX: to move the raw pointer into spawn_blocking
struct NativePtr(*mut RDKafka);
unsafe impl Send for NativePtr {}

let topic_c = CString::new(topic.to_string())?;
let native_client = unsafe { NativeClient::from_ptr(self.native_ptr()) };
let native_ptr = NativePtr(self.native_ptr());

tokio::task::spawn_blocking(move || unsafe {
let mut low = -1;
let mut high = -1;
let native_ptr = native_ptr;
let ret = rdsys::rd_kafka_query_watermark_offsets(
native_client.ptr(),
native_ptr.0,
topic_c.as_ptr(),
partition,
&mut low as *mut i64,
&mut high as *mut i64,
&mut low,
&mut high,
timeout.into().as_millis(),
);
if ret.is_error() {
Expand Down

0 comments on commit 4a8b518

Please sign in to comment.