Skip to content

Commit

Permalink
fix(configurer): block on waiting for the first message (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
laplab authored Jul 6, 2023
1 parent b66cc13 commit 1723d39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - ReleaseDate

### Fixed
- configurer: fix data race with empty mailbox ([#97])

[#97]: https://github.com/elfo-rs/elfo/pull/97

## [0.2.0-alpha.3] - 2023-07-05
### Added
- context: add `Context::set_restart_policy` to override a group's default restart policy ([#48]).
Expand Down
11 changes: 5 additions & 6 deletions elfo-configurer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tracing::{debug, error, info, warn};

use elfo_core::{
config::AnyConfig,
errors::{RequestError, TryRecvError},
errors::RequestError,
messages::{
EntrypointError, Ping, StartEntrypoint, StartEntrypointRejected, UpdateConfig,
ValidateConfig,
Expand Down Expand Up @@ -80,8 +80,8 @@ impl Configurer {

async fn main(mut self) {
let mut validated_configs = false;
let mut first_envelope = match self.ctx.try_recv().await {
Ok(e) => {
let mut first_envelope = match self.ctx.recv().await {
Some(e) => {
msg!(match e {
// We do not expect the first message to be `ConfigUpdated` because when the
// actor is first started, `UpdateConfig` is consumed by the supervisor.
Expand Down Expand Up @@ -126,9 +126,8 @@ impl Configurer {
e => Some(e),
})
}
Err(TryRecvError::Empty) => None,
// We treat `Closed` as a symptom of termination and stop the actor straightaway.
Err(TryRecvError::Closed) => return,
// We treat `None` as a symptom of termination and stop the actor straightaway.
None => return,
};

// Reload and validate configs in case the actor was restarted by the
Expand Down

0 comments on commit 1723d39

Please sign in to comment.