22// SPDX-License-Identifier: Apache-2.0
33
44use crate :: enter_listener_loop;
5- use crate :: setup:: pid_shm_path;
6- use datadog_ipc:: platform:: {
7- named_pipe_name_from_raw_handle, FileBackedHandle , MappedMem , NamedShmHandle ,
8- } ;
5+ use datadog_ipc:: platform:: named_pipe_name_from_raw_handle;
96use datadog_ipc:: { SeqpacketConn , SeqpacketListener } ;
107
118use futures:: FutureExt ;
@@ -62,19 +59,6 @@ pub extern "C" fn ddog_daemon_entry_point(_trampoline_data: &TrampolineData) {
6259 let pid = unsafe { libc:: getpid ( ) } ;
6360
6461 if let Some ( handle) = spawn_worker:: recv_passed_handle ( ) {
65- let mut shm = match named_pipe_name_from_raw_handle ( handle. as_raw_handle ( ) )
66- . ok_or ( io:: Error :: from ( io:: ErrorKind :: InvalidInput ) )
67- . and_then ( |name| NamedShmHandle :: create ( pid_shm_path ( & name) , 4 ) )
68- . and_then ( FileBackedHandle :: map)
69- {
70- Ok ( ok) => ok,
71- Err ( err) => {
72- error ! ( "Couldn't store pid to shared memory: {err}" ) ;
73- return ;
74- }
75- } ;
76- shm. as_slice_mut ( ) . copy_from_slice ( & pid. to_ne_bytes ( ) ) ;
77-
7862 info ! ( "Starting sidecar, pid: {}" , pid) ;
7963
8064 let acquire_listener = move || {
@@ -88,10 +72,8 @@ pub extern "C" fn ddog_daemon_entry_point(_trampoline_data: &TrampolineData) {
8872 }
8973 } ;
9074
91- // We pass the shm to ensure we drop the shm handle with the pid immediately after
92- // cancellation To avoid actual race conditions
9375 Ok ( (
94- |handler| accept_socket_loop ( listener, closed_future, handler, shm ) ,
76+ |handler| accept_socket_loop ( listener, closed_future, handler) ,
9577 cancel,
9678 ) )
9779 } ;
@@ -112,7 +94,6 @@ async fn accept_socket_loop(
11294 listener : SeqpacketListener ,
11395 cancellation : ManualFuture < ( ) > ,
11496 handler : Box < dyn Fn ( SeqpacketConn ) > ,
115- _: MappedMem < NamedShmHandle > ,
11697) -> io:: Result < ( ) > {
11798 // Wrap the first server instance as a Tokio NamedPipeServer for async connect polling.
11899 // After each accepted connection we create a fresh Tokio server for the next client.
@@ -144,7 +125,6 @@ async fn accept_socket_loop(
144125 let conn = SeqpacketConn :: from_server_handle ( owned, client_pid) ;
145126 handler ( conn) ;
146127 }
147- // drops pipe and shm here
148128 Ok ( ( ) )
149129}
150130
0 commit comments