Skip to content

Commit 891a058

Browse files
committed
Fixes
Signed-off-by: Bob Weinand <[email protected]>
1 parent 42df0f3 commit 891a058

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

live-debugger-ffi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ percent-encoding = "2.1"
1717
uuid = { version = "1.7.0", features = ["v4"] }
1818
serde_json = "1.0"
1919
tokio = "1.36.0"
20+
tokio-util = { version = "0.7", features = ["rt"] }
2021
log = "0.4.21"
2122

2223
[features]

live-debugger-ffi/src/data.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ impl<'a> From<&'a datadog_live_debugger::SpanDecorationProbe> for SpanDecoration
121121
span_tags: tags.as_ptr(),
122122
span_tags_num: tags.len(),
123123
};
124+
std::mem::forget(conditions);
124125
std::mem::forget(tags);
125126
new
126127
}
@@ -139,7 +140,7 @@ impl<'a> Drop for SpanDecorationProbe<'a> {
139140
);
140141
let num_conditions = tags.iter().filter(|p| p.next_condition).count();
141142
_ = Vec::from_raw_parts(
142-
self.conditions as *mut ProbeCondition,
143+
self.conditions as *mut &ProbeCondition,
143144
num_conditions,
144145
num_conditions,
145146
);

live-debugger-ffi/src/evaluator.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,8 @@ pub fn ddog_evaluate_string<'a>(
236236
) -> Cow<'a, str> {
237237
let mut ctx = EvalCtx::new(context);
238238
let (result, new_errors) = datadog_live_debugger::eval_string(&mut ctx, condition);
239-
if !new_errors.is_empty() {
240-
*errors = Some(Box::new(new_errors));
241-
}
239+
let found_errors = if !new_errors.is_empty() { Some(Box::new(new_errors)) } else { None };
240+
std::mem::forget(std::mem::replace(errors, found_errors));
242241
result
243242
}
244243

live-debugger-ffi/src/sender.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use percent_encoding::{percent_encode, CONTROLS};
1111
use std::sync::Arc;
1212
use std::thread::JoinHandle;
1313
use tokio::sync::mpsc;
14+
use tokio_util::task::TaskTracker;
1415

1516
macro_rules! try_c {
1617
($failable:expr) => {
@@ -46,6 +47,7 @@ async fn sender_routine(
4647
mut receiver: mpsc::Receiver<SendData>,
4748
) {
4849
let tags = Arc::new(tags);
50+
let tracker = TaskTracker::new();
4951
loop {
5052
let data = match receiver.recv().await {
5153
None => break,
@@ -54,7 +56,7 @@ async fn sender_routine(
5456

5557
let endpoint = endpoint.clone();
5658
let tags = tags.clone();
57-
tokio::spawn(async move {
59+
tracker.spawn(async move {
5860
let data = match &data {
5961
SendData::Raw(vec) => vec.as_slice(),
6062
SendData::Wrapped(wrapped) => wrapped.slice.as_bytes(),
@@ -65,6 +67,8 @@ async fn sender_routine(
6567
}
6668
});
6769
}
70+
71+
tracker.wait().await;
6872
}
6973

7074
pub struct SenderHandle {

live-debugger/src/redacted_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ lazy_static! {
8686
REDACTED_TYPES_INITIALIZED.store(true, Ordering::Relaxed);
8787
Regex::new(&REDACTED_WILDCARD_TYPES_PATTERN).unwrap()
8888
};
89-
89+
9090
static ref ASSUMED_SAFE_NAME_LEN: usize = {
9191
REDACTED_NAMES_INITIALIZED.store(true, Ordering::Relaxed);
9292
REDACTED_NAMES.iter().map(|n| n.len()).max().unwrap() + 5

0 commit comments

Comments
 (0)