Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Primarily reduces duplicate dependencies with different versions to reduce binary size slightly.

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi committed Oct 10, 2024
1 parent f363618 commit 0e573f3
Show file tree
Hide file tree
Showing 18 changed files with 1,917 additions and 3,626 deletions.
392 changes: 89 additions & 303 deletions Cargo.lock

Large diffs are not rendered by default.

4,999 changes: 1,758 additions & 3,241 deletions LICENSE-3rdparty.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default = []
cbindgen = []

[dependencies]
cbindgen = {version = "0.26"}
cbindgen = {version = "0.27"}
serde = "1.0"
serde_json = "1.0"

Expand Down
2 changes: 1 addition & 1 deletion crashtracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ blazesym = "0.2.0-rc.0"

[dependencies]
anyhow = "1.0"
backtrace = "0.3.69"
backtrace = "0.3.74"
chrono = {version = "0.4", default-features = false, features = ["std", "clock", "serde"]}
ddcommon = {path = "../ddcommon"}
hyper = {version = "0.14", features = ["client"], default-features = false}
Expand Down
2 changes: 1 addition & 1 deletion ddcommon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ log = { version = "0.4" }
pin-project = "1"
regex = "1.5"
rustls = { version = "0.23", default-features = false }
rustls-native-certs = { version = "0.6" }
rustls-native-certs = { version = "0.7" }
tokio = { version = "1.23", features = ["rt", "macros"] }
tokio-rustls = { version = "0.26", default-features = false }
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 0 additions & 2 deletions ddcommon/src/connector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ fn load_root_certs() -> anyhow::Result<rustls::RootCertStore> {
let mut roots = rustls::RootCertStore::empty();

for cert in rustls_native_certs::load_native_certs()? {
let cert = CertificateDer::from(cert.0);

//TODO: log when invalid cert is loaded
roots.add(cert).ok();
}
Expand Down
2 changes: 1 addition & 1 deletion ddtelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tokio-util = { version = "0.7", features = ["codec"] }
io-lifetimes = { version = "1.0" }
tracing = { version = "0.1", default-features = false }
uuid = { version = "1.3", features = ["v4"] }
hashbrown = { version = "0.12", features = ["raw"] }
hashbrown = { version = "0.14", features = ["raw"] }

[dev-dependencies]
tracing-subscriber = "0.3.18"
Expand Down
16 changes: 8 additions & 8 deletions ddtelemetry/src/worker/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod queuehasmpap {

pub struct QueueHashMap<K, V> {
table: RawTable<usize>,
hash_buidler: DefaultHashBuilder,
hash_builder: DefaultHashBuilder,
items: VecDeque<(K, V)>,
popped: usize,
}
Expand Down Expand Up @@ -40,7 +40,7 @@ mod queuehasmpap {
// Remove the oldest item in the queue and return it
pub fn pop_front(&mut self) -> Option<(K, V)> {
let (k, v) = self.items.pop_front()?;
let hash = make_hash(&self.hash_buidler, &k);
let hash = make_hash(&self.hash_builder, &k);
let found = self.table.remove_entry(hash, |other| *other == self.popped);
debug_assert!(found.is_some());
debug_assert!(self.items.len() == self.table.len());
Expand All @@ -49,7 +49,7 @@ mod queuehasmpap {
}

pub fn get(&self, k: &K) -> Option<&V> {
let hash = make_hash(&self.hash_buidler, k);
let hash = make_hash(&self.hash_builder, k);
let idx = self
.table
.get(hash, |other| &self.items[other - self.popped].0 == k)?;
Expand All @@ -61,7 +61,7 @@ mod queuehasmpap {
}

pub fn get_mut_or_insert(&mut self, key: K, default: V) -> (&mut V, bool) {
let hash = make_hash(&self.hash_buidler, &key);
let hash = make_hash(&self.hash_builder, &key);
if let Some(&idx) = self
.table
.get(hash, |other| self.items[other - self.popped].0 == key)
Expand All @@ -76,7 +76,7 @@ mod queuehasmpap {
//
// If the key already exists, replace the previous value
pub fn insert(&mut self, key: K, value: V) -> (usize, bool) {
let hash = make_hash(&self.hash_buidler, &key);
let hash = make_hash(&self.hash_builder, &key);
if let Some(&idx) = self
.table
.get(hash, |other| self.items[other - self.popped].0 == key)
Expand All @@ -103,11 +103,11 @@ mod queuehasmpap {
table,
items,
popped,
hash_buidler,
hash_builder,
..
} = self;
table.insert(hash, item_index, |i| {
make_hash(hash_buidler, &items[i - *popped].0)
make_hash(hash_builder, &items[i - *popped].0)
});
self.items.push_back((key, value));
item_index
Expand All @@ -118,7 +118,7 @@ mod queuehasmpap {
fn default() -> Self {
Self {
table: RawTable::new(),
hash_buidler: DefaultHashBuilder::new(),
hash_builder: DefaultHashBuilder::default(),
items: VecDeque::new(),
popped: 0,
}
Expand Down
4 changes: 2 additions & 2 deletions ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pin-project = { version = "1" }
memfd = { version = "0.6" }
serde = { version = "1.0", default-features = false, features = ["derive"] }
tokio-serde = { version = "0.8", features = ["bincode"] }
tokio-util = { version = "0.6.9", features = ["codec"] }
tokio-util = { version = "0.7.11", features = ["codec"] }
libc = { version = "0.2" }
tinybytes = { path = "../tinybytes", optional = true }

Expand All @@ -42,7 +42,7 @@ tracing-subscriber = { version = "0.3.11" }
spawn_worker = { path = "../spawn_worker" }

[target.'cfg(not(windows))'.dependencies]
nix = { version = "0.26.2", features = ["socket", "mman"] }
nix = { version = "0.27.1", features = ["mman", "socket", "poll"] }
sendfd = { version = "0.4", features = ["tokio"] }
tokio = { version = "1.23", features = ["sync", "io-util", "signal"] }

Expand Down
4 changes: 1 addition & 3 deletions ipc/src/platform/mem_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
use crate::handles::{HandlesTransport, TransferHandles};
use crate::platform::{mmap_handle, munmap_handle, OwnedFileHandle, PlatformHandle};
use serde::{Deserialize, Serialize};
#[cfg(all(unix, not(target_os = "macos")))]
use std::os::unix::prelude::AsRawFd;
use std::{ffi::CString, io};
#[cfg(feature = "tiny-bytes")]
use tinybytes::UnderlyingBytes;
Expand Down Expand Up @@ -90,7 +88,7 @@ where
self.set_mapping_size(size)?;
}
nix::unistd::ftruncate(
self.get_shm().handle.as_raw_fd(),
self.get_shm().handle.as_owned_fd()?,
self.get_shm().size as libc::off_t,
)?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion ipc/src/platform/unix/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Channel {
}

pub fn probe_readable(&self) -> bool {
let raw_fd = self.inner.as_raw_fd();
let raw_fd = self.inner.as_owned_fd().unwrap();
let mut fds = FdSet::new();
fds.insert(raw_fd);
nix::sys::select::select(None, Some(&mut fds), None, None, Some(&mut TimeVal::zero()))
Expand Down
28 changes: 13 additions & 15 deletions ipc/src/platform/unix/mem_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ use std::fs::File;
use std::io;
use std::num::NonZeroUsize;
use std::os::unix::fs::MetadataExt;
use std::os::unix::prelude::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::sync::atomic::{AtomicI32, Ordering};

pub(crate) fn mmap_handle<T: FileBackedHandle>(handle: T) -> io::Result<MappedMem<T>> {
let fd: RawFd = handle.get_shm().handle.as_raw_fd();
let fd = handle.get_shm().handle.as_owned_fd()?;
Ok(MappedMem {
ptr: unsafe {
mmap(
None,
NonZeroUsize::new(handle.get_shm().size).unwrap(),
ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
MapFlags::MAP_SHARED,
fd,
Some(fd),
0,
)?
},
Expand All @@ -45,15 +44,15 @@ static ANON_SHM_ID: AtomicI32 = AtomicI32::new(0);

impl ShmHandle {
#[cfg(target_os = "linux")]
fn open_anon_shm() -> anyhow::Result<RawFd> {
fn open_anon_shm() -> anyhow::Result<OwnedFd> {
if let Ok(memfd) = memfd::MemfdOptions::default().create("anon-shm-handle") {
Ok(memfd.into_raw_fd())
Ok(memfd.into_file().into())
} else {
Self::open_anon_shm_generic()
}
}

fn open_anon_shm_generic() -> anyhow::Result<RawFd> {
fn open_anon_shm_generic() -> anyhow::Result<OwnedFd> {
let path = format!(
"/libdatadog-shm-anon-{}-{}",
unsafe { libc::getpid() },
Expand All @@ -69,14 +68,14 @@ impl ShmHandle {
}

#[cfg(not(target_os = "linux"))]
fn open_anon_shm() -> anyhow::Result<RawFd> {
fn open_anon_shm() -> anyhow::Result<OwnedFd> {
Self::open_anon_shm_generic()
}

pub fn new(size: usize) -> anyhow::Result<ShmHandle> {
let fd = Self::open_anon_shm()?;
let handle = unsafe { PlatformHandle::from_raw_fd(fd) };
ftruncate(fd, size as off_t)?;
let handle: PlatformHandle<OwnedFd> = fd.into();
ftruncate(handle.as_owned_fd()?, size as off_t)?;
Ok(ShmHandle { handle, size })
}
}
Expand All @@ -88,21 +87,20 @@ impl NamedShmHandle {

pub fn create_mode(path: CString, size: usize, mode: Mode) -> io::Result<NamedShmHandle> {
let fd = shm_open(path.as_bytes(), OFlag::O_CREAT | OFlag::O_RDWR, mode)?;
ftruncate(fd, size as off_t)?;
ftruncate(&fd, size as off_t)?;
Self::new(fd, Some(path), size)
}

pub fn open(path: &CStr) -> io::Result<NamedShmHandle> {
let fd = shm_open(path, OFlag::O_RDWR, Mode::empty())?;
let file: File = unsafe { OwnedFd::from_raw_fd(fd) }.into();
let file: File = shm_open(path, OFlag::O_RDWR, Mode::empty())?.into();
let size = file.metadata()?.size() as usize;
Self::new(file.into_raw_fd(), None, size)
Self::new(file.into(), None, size)
}

fn new(fd: RawFd, path: Option<CString>, size: usize) -> io::Result<NamedShmHandle> {
fn new(fd: OwnedFd, path: Option<CString>, size: usize) -> io::Result<NamedShmHandle> {
Ok(NamedShmHandle {
inner: ShmHandle {
handle: unsafe { PlatformHandle::from_raw_fd(fd) },
handle: fd.into(),
size,
},
path: path.map(|path| ShmPath { name: path }),
Expand Down
20 changes: 10 additions & 10 deletions ipc/src/platform/unix/mem_handle_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use nix::unistd::ftruncate;
use std::ffi::{CStr, CString};
use std::io;
use std::num::NonZeroUsize;
use std::os::fd::OwnedFd;
use std::os::unix::prelude::{AsRawFd, FromRawFd, RawFd};
use std::sync::atomic::{AtomicI32, AtomicUsize, Ordering};

Expand All @@ -21,7 +22,7 @@ const NOT_COMMITTED: usize = 1 << (usize::BITS - 1);

pub(crate) fn mmap_handle<T: FileBackedHandle>(mut handle: T) -> io::Result<MappedMem<T>> {
let shm = handle.get_shm_mut();
let fd: RawFd = shm.handle.as_raw_fd();
let fd = shm.handle.as_owned_fd()?;
if shm.size & NOT_COMMITTED != 0 {
shm.size &= !NOT_COMMITTED;
let page_size = NonZeroUsize::try_from(page_size::get()).unwrap();
Expand All @@ -31,7 +32,7 @@ pub(crate) fn mmap_handle<T: FileBackedHandle>(mut handle: T) -> io::Result<Mapp
page_size,
ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
MapFlags::MAP_SHARED,
fd,
Some(fd),
(MAPPING_MAX_SIZE - usize::from(page_size)) as off_t,
)?;
if shm.size == 0 {
Expand All @@ -50,7 +51,7 @@ pub(crate) fn mmap_handle<T: FileBackedHandle>(mut handle: T) -> io::Result<Mapp
NonZeroUsize::new(shm.size).unwrap(),
ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
MapFlags::MAP_SHARED,
fd,
Some(fd),
0,
)?
},
Expand Down Expand Up @@ -78,11 +79,10 @@ impl ShmHandle {
OFlag::O_CREAT | OFlag::O_RDWR,
Mode::empty(),
)?;
ftruncate(fd, MAPPING_MAX_SIZE as off_t)?;
ftruncate(&fd, MAPPING_MAX_SIZE as off_t)?;
_ = shm_unlink(path.as_bytes());
let handle = unsafe { PlatformHandle::from_raw_fd(fd) };
Ok(ShmHandle {
handle,
handle: fd.into(),
size: size | NOT_COMMITTED,
})
}
Expand All @@ -99,7 +99,7 @@ impl NamedShmHandle {

pub fn create_mode(path: CString, size: usize, mode: Mode) -> io::Result<NamedShmHandle> {
let fd = shm_open(path_slice(&path), OFlag::O_CREAT | OFlag::O_RDWR, mode)?;
let truncate = ftruncate(fd, MAPPING_MAX_SIZE as off_t);
let truncate = ftruncate(&fd, MAPPING_MAX_SIZE as off_t);
if let Err(error) = truncate {
// ignore if already exists
if error != Errno::EINVAL {
Expand All @@ -114,10 +114,10 @@ impl NamedShmHandle {
Self::new(fd, None, 0)
}

fn new(fd: RawFd, path: Option<CString>, size: usize) -> io::Result<NamedShmHandle> {
fn new(fd: OwnedFd, path: Option<CString>, size: usize) -> io::Result<NamedShmHandle> {
Ok(NamedShmHandle {
inner: ShmHandle {
handle: unsafe { PlatformHandle::from_raw_fd(fd) },
handle: fd.into(),
size: size | NOT_COMMITTED,
},
path: path.map(|path| ShmPath { name: path }),
Expand Down Expand Up @@ -149,7 +149,7 @@ impl<T: FileBackedHandle + From<MappedMem<T>>> MappedMem<T> {
page_size,
ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
MapFlags::MAP_SHARED,
handle.get_shm().handle.fd,
Some(handle.get_shm().handle.as_owned_fd().unwrap()),
(MAPPING_MAX_SIZE - usize::from(page_size)) as off_t,
)
.unwrap();
Expand Down
12 changes: 5 additions & 7 deletions ipc/src/platform/unix/sockets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod linux {
io,
os::unix::{
net::{UnixListener, UnixStream},
prelude::{AsRawFd, FromRawFd, OsStrExt},
prelude::{AsRawFd, OsStrExt},
},
path::Path,
};
Expand All @@ -24,15 +24,13 @@ mod linux {
bind, connect, listen, socket, AddressFamily, SockFlag, SockType, UnixAddr,
};

fn socket_stream() -> io::Result<OwnedFd> {
let fd = socket(
fn socket_stream() -> nix::Result<OwnedFd> {
socket(
AddressFamily::Unix,
SockType::Stream,
SockFlag::SOCK_CLOEXEC,
None,
)?;

Ok(unsafe { OwnedFd::from_raw_fd(fd) })
)
}

pub fn connect_abstract<P: AsRef<Path>>(path: P) -> io::Result<UnixStream> {
Expand All @@ -46,7 +44,7 @@ mod linux {
let sock = socket_stream()?;
let addr = UnixAddr::new_abstract(path.as_ref().as_os_str().as_bytes())?;
bind(sock.as_raw_fd(), &addr)?;
listen(sock.as_raw_fd(), 128)?;
listen(&sock, 128)?;
Ok(sock.into())
}
}
Expand Down
2 changes: 1 addition & 1 deletion remote-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ datadog-trace-protobuf = { path = "../trace-protobuf" }
datadog-live-debugger = { path = "../live-debugger" }
hyper = { version = "0.14", features = ["client"], default-features = false }
http = "0.2"
base64 = "0.21.0"
base64 = "0.22.1"
sha2 = "0.10"
uuid = { version = "1.7.0", features = ["v4"] }
futures-util = "0.3"
Expand Down
Loading

0 comments on commit 0e573f3

Please sign in to comment.