[READ-ONLY] Mirror of https://github.com/SantaClaas/embedded-fan-control.

Record the subscribe acknowledgement instead of only logging it master

set_up_subscriptions logged a timeout error on every boot even though the broker had answered and the subscriptions worked afterwards. handle_subscribe_acknowledgement destructured the acknowledgement slot into _value purely as a bounds check and threw the binding away, so the bool it was meant to set stayed false forever. It never touched the waker either. The handler's whole effect was to validate the index and log, which is why the SUBACK showed up in the log and the waiter still ran into its 30 second timeout. Set the flag, and wake the waker after the guard is dropped so the waiter's try_lock succeeds when it polls again. Two ordering bugs in wait_for_acknowledgement would have bitten as soon as the flag was actually set, so fix them in the same pass. The waker was registered only in the else branch, after reading the array, which loses an acknowledgement recorded between the check and the registration. And the try_lock error branch returned Pending without ever registering a waker, which is a guaranteed sleep until the timeout. Registering before the check covers both, and re-checking after registering also handles an acknowledgement that was recorded before the first poll. Verified on device: the wait now completes in the same scheduler pass as the SUBACK and the error is gone from the boot log. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>


+59 -28
1 changed file