Skip to content

Commit

Permalink
fix(rust): fix BleTransport initialization race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinevg committed Feb 18, 2022
1 parent b2db7b4 commit 6d753cb
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ impl Worker for BleRouter {
type Message = RouterMessage;

async fn initialize(&mut self, ctx: &mut Context) -> Result<()> {
debug!("Registering Ble router for type = {}", crate::BLE);
ctx.register(crate::BLE, ctx.address()).await?;
ctx.set_cluster(crate::CLUSTER_NAME).await?;
Ok(())
}
Expand Down Expand Up @@ -134,9 +132,12 @@ impl BleRouter {

let handle = router.create_self_handle(ctx).await?;

trace!("BleRouter start_worker({:?})", addr.clone());
trace!("Start Ble router for address = {:?}", addr.clone());
ctx.start_worker(addr.clone(), router).await?;

trace!("Registering Ble router for type = {}", crate::BLE);
ctx.register(crate::BLE, ctx.address()).await?;

Ok(handle)
}
}

0 comments on commit 6d753cb

Please sign in to comment.