Skip to content

Commit 4fbcb70

Browse files
committed
No session ids
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
1 parent 3bf4217 commit 4fbcb70

6 files changed

Lines changed: 151 additions & 326 deletions

File tree

datadog-ipc/src/platform/unix/sockets/linux.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ impl SeqpacketListener {
2525
/// Removes any stale socket file before binding (standard Unix practice).
2626
pub fn bind(path: impl AsRef<Path>) -> io::Result<Self> {
2727
let _ = std::fs::remove_file(path.as_ref());
28-
let fd = create_seqpacket_socket()?;
2928
let addr = UnixAddr::new(path.as_ref()).map_err(io::Error::from)?;
30-
bind(fd.as_raw_fd(), &addr).map_err(io::Error::from)?;
31-
listen(&fd, Backlog::new(128).map_err(io::Error::from)?).map_err(io::Error::from)?;
32-
Ok(Self { inner: fd })
29+
Self::do_bind(addr)
3330
}
3431

3532
/// Bind to a Linux abstract socket name and start listening.
3633
pub fn bind_abstract(name: &[u8]) -> io::Result<Self> {
37-
let fd = create_seqpacket_socket()?;
3834
let addr = UnixAddr::new_abstract(name).map_err(io::Error::from)?;
35+
Self::do_bind(addr)
36+
}
37+
38+
fn do_bind(addr: UnixAddr) -> io::Result<Self> {
39+
let fd = create_seqpacket_socket()?;
3940
bind(fd.as_raw_fd(), &addr).map_err(io::Error::from)?;
40-
listen(&fd, Backlog::new(128).map_err(io::Error::from)?).map_err(io::Error::from)?;
41+
listen(&fd, Backlog::new(128).unwrap_or(Backlog::MAXCONN)).map_err(io::Error::from)?;
4142
Ok(Self { inner: fd })
4243
}
4344

datadog-sidecar-ffi/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,10 @@ pub unsafe extern "C" fn ddog_sidecar_session_set_config(
645645
#[allow(clippy::missing_safety_doc)]
646646
pub unsafe extern "C" fn ddog_sidecar_session_set_process_tags(
647647
transport: &mut Box<SidecarTransport>,
648-
session_id: ffi::CharSlice,
649648
process_tags: ffi::CharSlice,
650649
) -> MaybeError {
651650
try_c!(blocking::set_session_process_tags(
652651
transport,
653-
session_id.to_utf8_lossy().into(),
654652
process_tags.to_utf8_lossy().into(),
655653
));
656654

@@ -1272,12 +1270,10 @@ pub unsafe extern "C" fn ddog_sidecar_dogstatsd_set(
12721270
#[allow(clippy::missing_safety_doc)]
12731271
pub unsafe extern "C" fn ddog_sidecar_set_test_session_token(
12741272
transport: &mut Box<SidecarTransport>,
1275-
session_id: ffi::CharSlice,
12761273
token: ffi::CharSlice,
12771274
) -> MaybeError {
12781275
try_c!(blocking::set_test_session_token(
12791276
transport,
1280-
session_id.to_utf8_lossy().into_owned(),
12811277
token.to_utf8_lossy().into_owned(),
12821278
));
12831279

datadog-sidecar/src/service/blocking.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ pub fn shutdown_runtime(
173173
}
174174

175175
/// Shuts down a session.
176-
pub fn shutdown_session(transport: &mut SidecarTransport, session_id: String) -> io::Result<()> {
177-
lock_sender(transport)?.shutdown_session(session_id);
176+
pub fn shutdown_session(transport: &mut SidecarTransport) -> io::Result<()> {
177+
lock_sender(transport)?.shutdown_session();
178178
Ok(())
179179
}
180180

@@ -236,10 +236,9 @@ pub fn set_session_config(
236236
/// Updates the process tags for an existing session.
237237
pub fn set_session_process_tags(
238238
transport: &mut SidecarTransport,
239-
session_id: String,
240239
process_tags: String,
241240
) -> io::Result<()> {
242-
lock_sender(transport)?.set_session_process_tags(session_id, process_tags);
241+
lock_sender(transport)?.set_session_process_tags(process_tags);
243242
Ok(())
244243
}
245244

@@ -401,10 +400,9 @@ pub fn send_dogstatsd_actions(
401400
/// Sets x-datadog-test-session-token on all requests for the given session.
402401
pub fn set_test_session_token(
403402
transport: &mut SidecarTransport,
404-
session_id: String,
405403
token: String,
406404
) -> io::Result<()> {
407-
lock_sender(transport)?.set_test_session_token(session_id, token);
405+
lock_sender(transport)?.set_test_session_token(token);
408406
Ok(())
409407
}
410408

datadog-sidecar/src/service/sender.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,6 @@ fn cancel_if_instance(slot: &mut Option<SidecarInterfaceRequest>, instance_id: &
6969
}
7070
}
7171

72-
fn cancel_if_session(slot: &mut Option<SidecarInterfaceRequest>, session_id: &str) {
73-
let should_cancel = match slot {
74-
Some(SidecarInterfaceRequest::SetSessionConfig { session_id: id, .. }) => {
75-
id.as_str() == session_id
76-
}
77-
_ => false,
78-
};
79-
if should_cancel {
80-
*slot = None;
81-
}
82-
}
8372

8473
fn cancel_if_queue(
8574
slot: &mut Option<SidecarInterfaceRequest>,
@@ -109,8 +98,8 @@ fn coalesce(outbox: &mut SidecarOutbox, incoming: SidecarInterfaceRequest) {
10998
cancel_if_instance(&mut outbox.set_request_config, instance_id);
11099
cancel_if_instance(&mut outbox.set_universal_service_tags, instance_id);
111100
}
112-
if let SidecarInterfaceRequest::ShutdownSession { ref session_id } = incoming {
113-
cancel_if_session(&mut outbox.set_session_config, session_id);
101+
if matches!(incoming, SidecarInterfaceRequest::ShutdownSession {}) {
102+
outbox.set_session_config = None;
114103
}
115104
if let SidecarInterfaceRequest::ClearQueueId {
116105
ref instance_id,
@@ -231,13 +220,10 @@ impl SidecarSender {
231220
self.try_drain_outbox();
232221
}
233222

234-
pub fn set_session_process_tags(&mut self, session_id: String, process_tags: String) {
223+
pub fn set_session_process_tags(&mut self, process_tags: String) {
235224
coalesce(
236225
&mut self.outbox,
237-
SidecarInterfaceRequest::SetSessionProcessTags {
238-
session_id,
239-
process_tags,
240-
},
226+
SidecarInterfaceRequest::SetSessionProcessTags { process_tags },
241227
);
242228
self.try_drain_outbox();
243229
}
@@ -318,10 +304,10 @@ impl SidecarSender {
318304
self.try_drain_outbox();
319305
}
320306

321-
pub fn shutdown_session(&mut self, session_id: String) {
307+
pub fn shutdown_session(&mut self) {
322308
coalesce(
323309
&mut self.outbox,
324-
SidecarInterfaceRequest::ShutdownSession { session_id },
310+
SidecarInterfaceRequest::ShutdownSession {},
325311
);
326312
self.try_drain_outbox();
327313
}
@@ -428,12 +414,11 @@ impl SidecarSender {
428414
.try_send_send_dogstatsd_actions(instance_id, actions);
429415
}
430416

431-
pub fn set_test_session_token(&mut self, session_id: String, token: String) {
417+
pub fn set_test_session_token(&mut self, token: String) {
432418
if !self.try_drain_outbox() {
433419
return;
434420
}
435-
self.channel
436-
.try_send_set_test_session_token(session_id, token);
421+
self.channel.try_send_set_test_session_token(token);
437422
}
438423

439424
pub fn set_read_timeout(&mut self, d: Option<Duration>) -> io::Result<()> {

datadog-sidecar/src/service/sidecar_interface.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub trait SidecarInterface {
6161
///
6262
/// * `session_id` - The ID of the session.
6363
/// * `process_tags` - The process tags string.
64-
async fn set_session_process_tags(session_id: String, process_tags: String);
64+
async fn set_session_process_tags(process_tags: String);
6565

6666
/// Removes the application entry for the given queue ID from the instance.
6767
///
@@ -95,7 +95,7 @@ pub trait SidecarInterface {
9595
/// # Arguments
9696
///
9797
/// * `session_id` - The ID of the session.
98-
async fn shutdown_session(session_id: String);
98+
async fn shutdown_session();
9999

100100
/// Sends a trace via shared memory.
101101
///
@@ -214,7 +214,7 @@ pub trait SidecarInterface {
214214
///
215215
/// * `session_id` - The ID of the session.
216216
/// * `token` - The session token.
217-
async fn set_test_session_token(session_id: String, token: String);
217+
async fn set_test_session_token(token: String);
218218

219219
/// Sends a ping to the service.
220220
#[blocking]

0 commit comments

Comments
 (0)