Closed muzili closed 3 years ago
Hello @muzili,
welcome to iceoryx and thanks for reporting. That's a valid point and i guess it happens in timedSend
and timedReceive
where units::Duration
is used as timeout parameter. The timespec is there created based on units::TimeSpecReference::Epoch
which is CLOCK_REALTIME
. Changing that to units::TimeSpecReference::Monotonic
could resolve the issue.
See MessageQueue::timedSend(const std::string& msg, const units::Duration& timeout)
and MessageQueue::timedReceive(const units::Duration& timeout)
in message_queue.cpp in iceoryx_utils.
If you want you can contribute and create a PR with a solution proposal for review or we take it up, just let us know here.
@muzili correct me if I'm wrong, but mq_timedsend
requires an absolute timeout since 1970-01-01 00:00:00 +0000 (UTC)
. Doesn't this rule out CLOCK_MONOTONIC
?
@dkroenke @elBoberido This is the limitation for posix message queue, there's a detail explanation from https://stackoverflow.com/questions/33873374/pthreads-mq-timedreceive-pthread-cond-timedwait-and-clock-realtime
For QNX system, there's an alternative function mq_timedreceive_monotonic()
. For Posix(Linux) system, it is better to change to unix domain socket.
@muzili We have already planned to use UDS on in iceoryx: https://github.com/eclipse-iceoryx/iceoryx/issues/381. Hopefully in the next weeks it will come in.
@muzili for QNX we also plan to use message passing, so in the end the message queue won't be used anymore.
@muzili We have merged the UDS protocol in iceoryx and do not use the MessageQueue anymore. I tried to reproduce the issue locally on Ubuntu 20.04 and it does not come up. Can you confirm this?
Closing this as we use UDS now
Required information
The mq_timedsend/mq_timedreceive use CLOCK_REALTIME, there's unpredicated behaviour when the system time changes. The message queue should use CLOCK_MONOTONIC to fix this.
Operating system: Customized embedded linux
Compiler version: arm-himix200-linux-gcc (HC&C V1R3C00SPC200B005_20190606) 6.3.0
Observed result or behaviour: core/third_party/iceoryx-rs/iceoryx/iceoryx_utils/source/posix_wrapper/message_queue.cpp:305 { iox::cxx::expected<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iox::posix::IpcChannelError> iox::posix::MessageQueue::timedReceive(const iox::units::Duration&) const } ::: [ 22 ] Invalid argument
Expected result or behaviour: Works well with time changes.
Conditions where it occurred / Performed steps: Describe how one can reproduce the bug.
date -s '@2147483647'