Skip to content

Timeout weirdness in mqtt_run loop #81

@rmn30

Description

@rmn30

I noticed some weirdness in the mqtt_run function. Specifically:

  1. in the condition of the while loop

    } while (t->remaining > 0 && status != MQTTSuccess);
    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
    return -ETIMEDOUT;
    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 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.

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