Skip to content

Commit 601834c

Browse files
committed
fix(crashtracking): repair macOS sidecar connector
1 parent 0aa19a2 commit 601834c

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

components-rs/lib.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ fn reuse_sidecar_fd_connector(_unix_socket_path: &str) -> std::os::fd::RawFd {
324324
}
325325

326326
// Best-effort, signal context: read the transport pointer and get its current fd via
327-
// SidecarTransport::signal_fd (which uses get_mut, never locking). Going through the raw
327+
// SidecarTransport::as_raw_fd (which uses get_mut, never locking). Going through the raw
328328
// pointer knowingly bypasses aliasing checks — the crashing thread is the only realistic
329329
// accessor.
330330
let transport = unsafe { datadog_sidecar_for_signal }
@@ -334,7 +334,19 @@ fn reuse_sidecar_fd_connector(_unix_socket_path: &str) -> std::os::fd::RawFd {
334334
}
335335
let fd = unsafe { (*transport).as_raw_fd() };
336336
let bytes = crashtracker_receiver_request_bytes();
337-
let sent = unsafe { libc::send(dup, bytes.as_ptr() as *const libc::c_void, bytes.len(), 0) };
337+
let sent = unsafe {
338+
libc::send(
339+
fd,
340+
bytes.as_ptr().cast::<libc::c_void>(),
341+
bytes.len(),
342+
0,
343+
)
344+
};
345+
if sent == bytes.len() as isize {
346+
fd
347+
} else {
348+
-1
349+
}
338350
}
339351

340352
// Hack: Without this, the PECL build of the tracer does not contain the ddog_library_* functions

0 commit comments

Comments
 (0)