Skip to content

ControllerState.waker is never signaled #66

@sidit77

Description

@sidit77

Hi,

I'm currently through this project to get some inspiration on how to improve my own Bluetooth stack and I think I've stumbled on a small bug.

Currently the implementation of the ControllerState looks like this:

struct ControllerState<const SLOTS: usize> {
    ...
    waker: AtomicWaker,
}

impl<const SLOTS: usize> ControllerState<SLOTS> {
    async fn acquire(&self, op: cmd::Opcode, event: *mut [u8]) -> (&Signal<NoopRawMutex, CommandResponse>, usize) {
        ...
        poll_fn(|cx| match self.acquire_slot(op, event) {
            Some(ret) => Poll::Ready(ret),
            None => {
                self.waker.register(cx.waker()); // <-- Waker is registered here if no viable slot is available
                Poll::Pending
            }
        })
        .await
    }
}

However, the implementation never calls self.waker.wake(). Unless I'm mistaken, this should cause the ControllerState::acquire to potentially stall indefinitely.

I think the correct action is to add a self.waker.wake() call to ControllerState::release_slot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions