CHERIoT-Platform / CHERIoT-Platform/network-stack

Timeout weirdness in mqtt_run loop

Open
#81 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
9
Forks
14
Avg merge
6d 17h
Merged PRs (30d)
1

Description

I noticed some weirdness in the `mqtt_run` function. Specifically:

1) in the condition of the while loop https://github.com/CHERIoT-Platform/network-stack/blob/a7314f938e6f7cbb3cf125d77383e71a6d0ca22f/lib/mqtt/mqtt.cc#L1115 I don't think `status != MQTT_Success` is ever true because if it were we would've hit one of the return statements above. This means the loop always executes exactly once, so what's the point of having a loop?! For the same reason I don't think the return at https://github.com/CHERIoT-Platform/network-stack/blob/a7314f938e6f7cbb3cf125d77383e71a6d0ca22f/lib/mqtt/mqtt.cc#L1119 is ever reachable so the function will never return `-ETIMEDOUT`.

2) Relatedly, although the function takes a Timeout and elapses it, it will call `MQTT_ProcessLoop` (which I presume may block?) even if `timeout->may_block()` is false. Is this the correct behaviour?

I noticed this because this function is called in a loop in the Hugh demo [here](https://github.com/CHERIoT-Platform/cheriot-demos/blob/755fc02598dd71c39a3ddc0f5198db0d0307a49d/HughTheLightbulbV2/Device/mqtt.cc#L234) and I noticed that it never timed out in long runs even though the timeout was never reset. This is harmless in this case and actually what we want, but it's weird.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.