diff options
| author | kbleeke <[email protected]> | 2023-04-25 19:08:47 +0200 |
|---|---|---|
| committer | kbleeke <[email protected]> | 2023-04-25 19:14:00 +0200 |
| commit | 9e96655757180d7fe32ebff1ed93a35a4c3cff28 (patch) | |
| tree | 6bfce219cf894a0b7f927fd52e7792977570933d | |
| parent | 582a15a69320d987de5db3121af2f805f8508a6b (diff) | |
comment some choices for current event handling
| -rw-r--r-- | src/control.rs | 6 | ||||
| -rw-r--r-- | src/runner.rs | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/control.rs b/src/control.rs index 824c55125..0c06009b9 100644 --- a/src/control.rs +++ b/src/control.rs | |||
| @@ -197,18 +197,20 @@ impl<'a> Control<'a> { | |||
| 197 | async fn wait_for_join(&mut self, i: SsidInfo) { | 197 | async fn wait_for_join(&mut self, i: SsidInfo) { |
| 198 | self.events.mask.enable(&[Event::JOIN, Event::AUTH]); | 198 | self.events.mask.enable(&[Event::JOIN, Event::AUTH]); |
| 199 | let mut subscriber = self.events.queue.subscriber().unwrap(); | 199 | let mut subscriber = self.events.queue.subscriber().unwrap(); |
| 200 | // the actual join operation starts here | ||
| 201 | // we make sure to enable events before so we don't miss any | ||
| 200 | self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes()) | 202 | self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes()) |
| 201 | .await; | 203 | .await; |
| 202 | // set_ssid | 204 | // set_ssid |
| 203 | 205 | ||
| 204 | loop { | 206 | loop { |
| 205 | let msg = subscriber.next_message_pure().await; | 207 | let msg = subscriber.next_message_pure().await; |
| 206 | if msg.header.event_type == Event::AUTH && msg.header.status != 0 { | 208 | if msg.header.event_type == Event::AUTH && msg.header.status != EStatus::SUCCESS { |
| 207 | // retry | 209 | // retry |
| 208 | warn!("JOIN failed with status={}", msg.header.status); | 210 | warn!("JOIN failed with status={}", msg.header.status); |
| 209 | self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes()) | 211 | self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes()) |
| 210 | .await; | 212 | .await; |
| 211 | } else if msg.header.event_type == Event::JOIN && msg.header.status == 0 { | 213 | } else if msg.header.event_type == Event::JOIN && msg.header.status == EStatus::SUCCESS { |
| 212 | // successful join | 214 | // successful join |
| 213 | break; | 215 | break; |
| 214 | } | 216 | } |
diff --git a/src/runner.rs b/src/runner.rs index 554a711d8..806ddfc49 100644 --- a/src/runner.rs +++ b/src/runner.rs | |||
| @@ -406,6 +406,10 @@ where | |||
| 406 | let status = event_packet.msg.status; | 406 | let status = event_packet.msg.status; |
| 407 | let event_payload = events::Payload::None; | 407 | let event_payload = events::Payload::None; |
| 408 | 408 | ||
| 409 | // this intentionally uses the non-blocking publish immediate | ||
| 410 | // publish() is a deadlock risk in the current design as awaiting here prevents ioctls | ||
| 411 | // The `Runner` always yields when accessing the device, so consumers always have a chance to receive the event | ||
| 412 | // (if they are actively awaiting the queue) | ||
| 409 | self.events.queue.publish_immediate(events::Message::new( | 413 | self.events.queue.publish_immediate(events::Message::new( |
| 410 | Status { | 414 | Status { |
| 411 | event_type: evt_type, | 415 | event_type: evt_type, |
