Skip to content

Failure with kernels not supporting CLOCK_BOOTTIME #3089

@diego-santacruz

Description

@diego-santacruz

I need to run mosquitto (client using libmosquitto) on a platform which has a Linux kernel without CLOCK_BOOTTIME but where the libc headers declare CLOCK_BOOTTIME, since they are decoupled from the kernel itself.

Under these circumstances libmosquitto goes crazy and fails with Keepalive exceeded errors. I traced the issue to mosquitto_time() that will do clock_gettime(CLOCK_BOOTTIME, &tp) if CLOCK_BOOTTIME is defined by the libc headers, without checking the return value. Since on this platform there is no CLOCK_BOOTTIME the call returns -EINVAL and the value returned by mosquitto_time() is basically garbage, so any timestamp comparisons go haywire.

The fix is relatively simple, and basically boils down to probing, at runtime, for CLOCK_BOOTTIME and using CLOCK_MONOTONIC as fallback.

Mosquitto version: 2.0.18

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