Fix UDP hangups at boot, check in cargo config

This commit is contained in:
Joey Hines 2025-08-31 18:49:11 -06:00
parent 0c0fe9c87d
commit d51bf370f3
Signed by: joeyahines
GPG Key ID: 38BA6F25C94C9382
3 changed files with 3 additions and 10 deletions

2
.cargo/config.toml Normal file
View File

@ -0,0 +1,2 @@
[registries.ahines]
index = "https://git.ahines.net/joeyahines/_cargo-index.git"

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
/target /target
config.toml /config.toml

View File

@ -10,7 +10,6 @@ const BUFFER_SIZE: usize = 64 * 1024;
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct CircularBufferSource { pub struct CircularBufferSource {
condvar: Arc<Condvar>,
circular_buffer: Arc<Mutex<CircularBuffer<BUFFER_SIZE, u8>>>, circular_buffer: Arc<Mutex<CircularBuffer<BUFFER_SIZE, u8>>>,
} }
@ -20,7 +19,6 @@ impl Read for CircularBufferSource {
if circ_buffer.is_empty() { if circ_buffer.is_empty() {
buf.fill(0); buf.fill(0);
self.condvar.notify_all();
return Ok(buf.len()); return Ok(buf.len());
} }
@ -30,8 +28,6 @@ impl Read for CircularBufferSource {
buf[ndx] = value; buf[ndx] = value;
} }
self.condvar.notify_all();
Ok(bytes_to_read) Ok(bytes_to_read)
} }
} }
@ -40,12 +36,7 @@ impl Write for CircularBufferSource {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
let mut circ_buffer = self.circular_buffer.lock().expect("Mutex was poisoned"); let mut circ_buffer = self.circular_buffer.lock().expect("Mutex was poisoned");
while circ_buffer.len() + buf.len() > BUFFER_SIZE {
circ_buffer = self.condvar.wait(circ_buffer).expect("Mutex was poisoned");
}
circ_buffer.extend_from_slice(buf); circ_buffer.extend_from_slice(buf);
self.condvar.notify_all();
Ok(buf.len()) Ok(buf.len())
} }