Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AP-1055] handle possible race condition in reading settings #96

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ use crate::error::{BoxedError, Error};
use crate::setting::{Setting, SettingValue};

const SENDER_ID: u16 = 0x42;
// Right now there is a race in the reading of the settings, a signal that
// the settings is finished can be sent before all the settings have been
// received. Do not increase the number of workers until this race condition
// has been fixed
const NUM_WORKERS: usize = 10;

pub struct Client<'a> {
Expand Down Expand Up @@ -136,7 +140,7 @@ impl<'a> Client<'a> {
}

fn read_all_inner(&mut self, ctx: Context) -> (Vec<Entry>, Vec<Error>) {
let (done_tx, done_rx) = crossbeam_channel::bounded(NUM_WORKERS);
let (done_tx, done_rx) = crossbeam_channel::bounded(1);
let done_key = self.link.register(move |_: MsgSettingsReadByIndexDone| {
for _ in 0..NUM_WORKERS {
let _ = done_tx.try_send(());
Expand Down
Loading