New Integration of sd-event loop
hellow554 opened this issue · 10 comments
On the release/v2.0
branch there is an ongoing work to integrate this library with the sd-event loop.
Currently, I'm not able to have it working, because as soon as I try to run the event loop, it errors out with -EINVAL
, because of one of the timerfd syscalls returns EINVAL
(strace of my program):
timerfd_settime(12, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=-1, tv_nsec=4294967295}}, NULL) = -1 EINVAL (Invalid argument)
After investigating the attachSdEventLoop
function a bit, I wonder why you don't use the sd_bus_attach_event
at all? Wouldn't that be much simpler?
Currently, I'm not able to have it working,
Are sdbus-c++ integration tests passing for you? They all also run in a configuration based on sd-event loop, which verifies the sd-event integration functionality.
I wonder why you don't use the sd_bus_attach_event
Yes, it would be simpler. But that would get things wired directly in sd-bus, completely bypassing sdbus-c++ layer, which would break all the guarantees provided by sdbus-c++. So we have to have our own integration (and this integration is very similar to the one in sd-bus, but uses sdbus-c++ callback functions instead of sd-bus callback functions).
Thanks for your answer and sorry for the delay, I had urgent work to do.
The integration tests are not successful for me on my arm machine 6.1.5-xilinx-v2022.2 #1 SMP PREEMPT Wed May 10 15:52:51 UTC 2023 armv7l GNU/Linux
:
Integration test output
# ./sdbus-c++-integration-tests
[==========] Running 149 tests from 10 test suites.
[----------] Global test environment set-up.
[----------] 6 tests from Connection
[ RUN ] Connection.CanBeDefaultConstructed
[ OK ] Connection.CanBeDefaultConstructed (2 ms)
[ RUN ] Connection.CanRequestRegisteredDbusName
[ OK ] Connection.CanRequestRegisteredDbusName (16 ms)
[ RUN ] Connection.CannotRequestNonregisteredDbusName
[ OK ] Connection.CannotRequestNonregisteredDbusName (3 ms)
[ RUN ] Connection.CanReleasedRequestedName
[ OK ] Connection.CanReleasedRequestedName (16 ms)
[ RUN ] Connection.CannotReleaseNonrequestedName
[ OK ] Connection.CannotReleaseNonrequestedName (17 ms)
[ RUN ] Connection.CanEnterAndLeaveInternalEventLoop
[ OK ] Connection.CanEnterAndLeaveInternalEventLoop (9 ms)
[----------] 6 tests from Connection (66 ms total)
[----------] 1 test from AdaptorAndProxy
[ RUN ] AdaptorAndProxy.CanBeConstructedSuccesfully
[ OK ] AdaptorAndProxy.CanBeConstructedSuccesfully (22 ms)
[----------] 1 test from AdaptorAndProxy (23 ms total)
[----------] 1 test from AProxy
[ RUN ] AProxy.SupportsMoveSemantics
[ OK ] AProxy.SupportsMoveSemantics (0 ms)
[----------] 1 test from AProxy (0 ms total)
[----------] 1 test from AnAdaptor
[ RUN ] AnAdaptor.SupportsMoveSemantics
[ OK ] AnAdaptor.SupportsMoveSemantics (0 ms)
[----------] 1 test from AnAdaptor (0 ms total)
[----------] 4 tests from AConnection/0, where TypeParam = sdbus::test::SdBusCppLoop
[ RUN ] AConnection/0.WillCallCallbackHandlerForIncomingMessageMatchingMatchRule
[ OK ] AConnection/0.WillCallCallbackHandlerForIncomingMessageMatchingMatchRule (13 ms)
[ RUN ] AConnection/0.WillUnsubscribeMatchRuleWhenClientDestroysTheAssociatedSlot
[ OK ] AConnection/0.WillUnsubscribeMatchRuleWhenClientDestroysTheAssociatedSlot (1041 ms)
[ RUN ] AConnection/0.CanAddFloatingMatchRule
[ OK ] AConnection/0.CanAddFloatingMatchRule (1049 ms)
[ RUN ] AConnection/0.WillNotPassToMatchCallbackMessagesThatDoNotMatchTheRule
[ OK ] AConnection/0.WillNotPassToMatchCallbackMessagesThatDoNotMatchTheRule (1041 ms)
[----------] 4 tests from AConnection/0 (3146 ms total)
[----------] 4 tests from AConnection/1, where TypeParam = sdbus::test::SdEventLoop
[ RUN ] AConnection/1.WillCallCallbackHandlerForIncomingMessageMatchingMatchRule
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusGeneralTests.cpp:85: Failure
Value of: this->waitUntil(matchingMessageReceived)
Actual: false
Expected: true
[ FAILED ] AConnection/1.WillCallCallbackHandlerForIncomingMessageMatchingMatchRule, where TypeParam = sdbus::test::SdEventLoop (5086 ms)
[ RUN ] AConnection/1.WillUnsubscribeMatchRuleWhenClientDestroysTheAssociatedSlot
[ OK ] AConnection/1.WillUnsubscribeMatchRuleWhenClientDestroysTheAssociatedSlot (1029 ms)
[ RUN ] AConnection/1.CanAddFloatingMatchRule
[ OK ] AConnection/1.CanAddFloatingMatchRule (1045 ms)
[ RUN ] AConnection/1.WillNotPassToMatchCallbackMessagesThatDoNotMatchTheRule
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusGeneralTests.cpp:142: Failure
Value of: this->waitUntil([&](){ return numberOfMatchingMessages == 2; })
Actual: false
Expected: true
[ FAILED ] AConnection/1.WillNotPassToMatchCallbackMessagesThatDoNotMatchTheRule, where TypeParam = sdbus::test::SdEventLoop (5089 ms)
[----------] 4 tests from AConnection/1 (12250 ms total)
[----------] 55 tests from SdbusTestObject/0, where TypeParam = sdbus::test::SdBusCppLoop
[ RUN ] SdbusTestObject/0.CallsEmptyMethodSuccesfully
[ OK ] SdbusTestObject/0.CallsEmptyMethodSuccesfully (8 ms)
[ RUN ] SdbusTestObject/0.CallsMethodsWithBaseTypesSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodsWithBaseTypesSuccesfully (28 ms)
[ RUN ] SdbusTestObject/0.CallsMethodsWithTuplesSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodsWithTuplesSuccesfully (17 ms)
[ RUN ] SdbusTestObject/0.CallsMethodsWithStructSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodsWithStructSuccesfully (16 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithVariantSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodWithVariantSuccesfully (19 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithStructVariantsAndGetMapSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodWithStructVariantsAndGetMapSuccesfully (18 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithStructInStructSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodWithStructInStructSuccesfully (20 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithTwoStructsSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodWithTwoStructsSuccesfully (18 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithTwoVectorsSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodWithTwoVectorsSuccesfully (19 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithSignatureSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodWithSignatureSuccesfully (19 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithObjectPathSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodWithObjectPathSuccesfully (21 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithUnixFdSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodWithUnixFdSuccesfully (19 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithComplexTypeSuccesfully
[ OK ] SdbusTestObject/0.CallsMethodWithComplexTypeSuccesfully (24 ms)
[ RUN ] SdbusTestObject/0.CallsMultiplyMethodWithNoReplyFlag
[ OK ] SdbusTestObject/0.CallsMultiplyMethodWithNoReplyFlag (13 ms)
[ RUN ] SdbusTestObject/0.CallsMethodWithCustomTimeoutSuccessfully
[ OK ] SdbusTestObject/0.CallsMethodWithCustomTimeoutSuccessfully (30 ms)
[ RUN ] SdbusTestObject/0.ThrowsTimeoutErrorWhenMethodTimesOut
[ OK ] SdbusTestObject/0.ThrowsTimeoutErrorWhenMethodTimesOut (9 ms)
[ RUN ] SdbusTestObject/0.CallsMethodThatThrowsError
[ OK ] SdbusTestObject/0.CallsMethodThatThrowsError (40 ms)
[ RUN ] SdbusTestObject/0.CallsErrorThrowingMethodWithDontExpectReplySet
[ OK ] SdbusTestObject/0.CallsErrorThrowingMethodWithDontExpectReplySet (25 ms)
[ RUN ] SdbusTestObject/0.FailsCallingNonexistentMethod
[ OK ] SdbusTestObject/0.FailsCallingNonexistentMethod (9 ms)
[ RUN ] SdbusTestObject/0.FailsCallingMethodOnNonexistentInterface
[ OK ] SdbusTestObject/0.FailsCallingMethodOnNonexistentInterface (23 ms)
[ RUN ] SdbusTestObject/0.FailsCallingMethodOnNonexistentDestination
[ OK ] SdbusTestObject/0.FailsCallingMethodOnNonexistentDestination (31 ms)
[ RUN ] SdbusTestObject/0.FailsCallingMethodOnNonexistentObject
[ OK ] SdbusTestObject/0.FailsCallingMethodOnNonexistentObject (35 ms)
[ RUN ] SdbusTestObject/0.CanReceiveSignalWhileMakingMethodCall
[ OK ] SdbusTestObject/0.CanReceiveSignalWhileMakingMethodCall (32 ms)
[ RUN ] SdbusTestObject/0.CanAccessAssociatedMethodCallMessageInMethodCallHandler
[ OK ] SdbusTestObject/0.CanAccessAssociatedMethodCallMessageInMethodCallHandler (28 ms)
[ RUN ] SdbusTestObject/0.CanAccessAssociatedMethodCallMessageInAsyncMethodCallHandler
[ OK ] SdbusTestObject/0.CanAccessAssociatedMethodCallMessageInAsyncMethodCallHandler (37 ms)
[ RUN ] SdbusTestObject/0.CanSetGeneralMethodTimeoutWithLibsystemdVersionGreaterThan239
[ OK ] SdbusTestObject/0.CanSetGeneralMethodTimeoutWithLibsystemdVersionGreaterThan239 (8 ms)
[ RUN ] SdbusTestObject/0.CanCallMethodSynchronouslyWithoutAnEventLoopThread
[ OK ] SdbusTestObject/0.CanCallMethodSynchronouslyWithoutAnEventLoopThread (30 ms)
[ RUN ] SdbusTestObject/0.EmitsSimpleSignalSuccesfully
[ OK ] SdbusTestObject/0.EmitsSimpleSignalSuccesfully (14 ms)
[ RUN ] SdbusTestObject/0.EmitsSimpleSignalToMultipleProxiesSuccesfully
[ OK ] SdbusTestObject/0.EmitsSimpleSignalToMultipleProxiesSuccesfully (46 ms)
[ RUN ] SdbusTestObject/0.ProxyDoesNotReceiveSignalFromOtherBusName
[ OK ] SdbusTestObject/0.ProxyDoesNotReceiveSignalFromOtherBusName (1052 ms)
[ RUN ] SdbusTestObject/0.EmitsSignalWithMapSuccesfully
[ OK ] SdbusTestObject/0.EmitsSignalWithMapSuccesfully (24 ms)
[ RUN ] SdbusTestObject/0.EmitsSignalWithLargeMapSuccesfully
[ OK ] SdbusTestObject/0.EmitsSignalWithLargeMapSuccesfully (807 ms)
[ RUN ] SdbusTestObject/0.EmitsSignalWithVariantSuccesfully
[ OK ] SdbusTestObject/0.EmitsSignalWithVariantSuccesfully (69 ms)
[ RUN ] SdbusTestObject/0.EmitsSignalWithoutRegistrationSuccesfully
[ OK ] SdbusTestObject/0.EmitsSignalWithoutRegistrationSuccesfully (14 ms)
[ RUN ] SdbusTestObject/0.CanAccessAssociatedSignalMessageInSignalHandler
[ OK ] SdbusTestObject/0.CanAccessAssociatedSignalMessageInSignalHandler (26 ms)
[ RUN ] SdbusTestObject/0.UnregistersSignalHandler
[ OK ] SdbusTestObject/0.UnregistersSignalHandler (1033 ms)
[ RUN ] SdbusTestObject/0.UnregistersSignalHandlerForSomeProxies
[ OK ] SdbusTestObject/0.UnregistersSignalHandlerForSomeProxies (1066 ms)
[ RUN ] SdbusTestObject/0.ReRegistersSignalHandler
[ OK ] SdbusTestObject/0.ReRegistersSignalHandler (1054 ms)
[ RUN ] SdbusTestObject/0.ReadsReadOnlyPropertySuccesfully
[ OK ] SdbusTestObject/0.ReadsReadOnlyPropertySuccesfully (13 ms)
[ RUN ] SdbusTestObject/0.FailsWritingToReadOnlyProperty
[ OK ] SdbusTestObject/0.FailsWritingToReadOnlyProperty (21 ms)
[ RUN ] SdbusTestObject/0.WritesAndReadsReadWritePropertySuccesfully
[ OK ] SdbusTestObject/0.WritesAndReadsReadWritePropertySuccesfully (22 ms)
[ RUN ] SdbusTestObject/0.CanAccessAssociatedPropertySetMessageInPropertySetHandler
[ OK ] SdbusTestObject/0.CanAccessAssociatedPropertySetMessageInPropertySetHandler (9 ms)
[ RUN ] SdbusTestObject/0.PingsViaPeerInterface
[ OK ] SdbusTestObject/0.PingsViaPeerInterface (31 ms)
[ RUN ] SdbusTestObject/0.AnswersMachineUuidViaPeerInterface
[ OK ] SdbusTestObject/0.AnswersMachineUuidViaPeerInterface (12 ms)
[ RUN ] SdbusTestObject/0.GetsPropertyViaPropertiesInterface
[ OK ] SdbusTestObject/0.GetsPropertyViaPropertiesInterface (21 ms)
[ RUN ] SdbusTestObject/0.SetsPropertyViaPropertiesInterface
[ OK ] SdbusTestObject/0.SetsPropertyViaPropertiesInterface (20 ms)
[ RUN ] SdbusTestObject/0.GetsAllPropertiesViaPropertiesInterface
[ OK ] SdbusTestObject/0.GetsAllPropertiesViaPropertiesInterface (18 ms)
[ RUN ] SdbusTestObject/0.EmitsPropertyChangedSignalForSelectedProperties
[ OK ] SdbusTestObject/0.EmitsPropertyChangedSignalForSelectedProperties (25 ms)
[ RUN ] SdbusTestObject/0.EmitsPropertyChangedSignalForAllProperties
[ OK ] SdbusTestObject/0.EmitsPropertyChangedSignalForAllProperties (24 ms)
[ RUN ] SdbusTestObject/0.GetsZeroManagedObjectsIfHasNoSubPathObjects
[ OK ] SdbusTestObject/0.GetsZeroManagedObjectsIfHasNoSubPathObjects (23 ms)
[ RUN ] SdbusTestObject/0.GetsManagedObjectsSuccessfully
[ OK ] SdbusTestObject/0.GetsManagedObjectsSuccessfully (11 ms)
[ RUN ] SdbusTestObject/0.EmitsInterfacesAddedSignalForSelectedObjectInterfaces
[ OK ] SdbusTestObject/0.EmitsInterfacesAddedSignalForSelectedObjectInterfaces (15 ms)
[ RUN ] SdbusTestObject/0.EmitsInterfacesAddedSignalForAllObjectInterfaces
[ OK ] SdbusTestObject/0.EmitsInterfacesAddedSignalForAllObjectInterfaces (29 ms)
[ RUN ] SdbusTestObject/0.EmitsInterfacesRemovedSignalForSelectedObjectInterfaces
[ OK ] SdbusTestObject/0.EmitsInterfacesRemovedSignalForSelectedObjectInterfaces (13 ms)
[ RUN ] SdbusTestObject/0.EmitsInterfacesRemovedSignalForAllObjectInterfaces
[ OK ] SdbusTestObject/0.EmitsInterfacesRemovedSignalForAllObjectInterfaces (26 ms)
[----------] 55 tests from SdbusTestObject/0 (6170 ms total)
[----------] 55 tests from SdbusTestObject/1, where TypeParam = sdbus::test::SdEventLoop
[ RUN ] SdbusTestObject/1.CallsEmptyMethodSuccesfully
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusMethodsTests.cpp:59: Failure
Expected: this->m_proxy->noArgNoReturn() doesn't throw an exception.
Actual: it throws sdbus::Error with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out".
[ FAILED ] SdbusTestObject/1.CallsEmptyMethodSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25028 ms)
[ RUN ] SdbusTestObject/1.CallsMethodsWithBaseTypesSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodsWithBaseTypesSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25029 ms)
[ RUN ] SdbusTestObject/1.CallsMethodsWithTuplesSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodsWithTuplesSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25025 ms)
[ RUN ] SdbusTestObject/1.CallsMethodsWithStructSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodsWithStructSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25024 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithVariantSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithVariantSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25033 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithStructVariantsAndGetMapSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithStructVariantsAndGetMapSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25032 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithStructInStructSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithStructInStructSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25023 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithTwoStructsSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithTwoStructsSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25010 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithTwoVectorsSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithTwoVectorsSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25032 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithSignatureSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithSignatureSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25032 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithObjectPathSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithObjectPathSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25033 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithUnixFdSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithUnixFdSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25030 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithComplexTypeSuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithComplexTypeSuccesfully, where TypeParam = sdbus::test::SdEventLoop (25032 ms)
[ RUN ] SdbusTestObject/1.CallsMultiplyMethodWithNoReplyFlag
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusMethodsTests.cpp:158: Failure
Value of: this->waitUntil(this->m_adaptor->m_wasMultiplyCalled)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.CallsMultiplyMethodWithNoReplyFlag, where TypeParam = sdbus::test::SdEventLoop (5081 ms)
[ RUN ] SdbusTestObject/1.CallsMethodWithCustomTimeoutSuccessfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CallsMethodWithCustomTimeoutSuccessfully, where TypeParam = sdbus::test::SdEventLoop (508 ms)
[ RUN ] SdbusTestObject/1.ThrowsTimeoutErrorWhenMethodTimesOut
[ OK ] SdbusTestObject/1.ThrowsTimeoutErrorWhenMethodTimesOut (7 ms)
[ RUN ] SdbusTestObject/1.CallsMethodThatThrowsError
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusMethodsTests.cpp:198: Failure
Value of: e.getName()
Expected: is equal to 0x4f16a8 pointing to "org.freedesktop.DBus.Error.AccessDenied"
Actual: "org.freedesktop.DBus.Error.Timeout"
[ FAILED ] SdbusTestObject/1.CallsMethodThatThrowsError, where TypeParam = sdbus::test::SdEventLoop (25029 ms)
[ RUN ] SdbusTestObject/1.CallsErrorThrowingMethodWithDontExpectReplySet
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusMethodsTests.cpp:211: Failure
Value of: this->waitUntil(this->m_adaptor->m_wasThrowErrorCalled)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.CallsErrorThrowingMethodWithDontExpectReplySet, where TypeParam = sdbus::test::SdEventLoop (5081 ms)
[ RUN ] SdbusTestObject/1.FailsCallingNonexistentMethod
[ OK ] SdbusTestObject/1.FailsCallingNonexistentMethod (25027 ms)
[ RUN ] SdbusTestObject/1.FailsCallingMethodOnNonexistentInterface
[ OK ] SdbusTestObject/1.FailsCallingMethodOnNonexistentInterface (25020 ms)
[ RUN ] SdbusTestObject/1.FailsCallingMethodOnNonexistentDestination
[ OK ] SdbusTestObject/1.FailsCallingMethodOnNonexistentDestination (14 ms)
[ RUN ] SdbusTestObject/1.FailsCallingMethodOnNonexistentObject
[ OK ] SdbusTestObject/1.FailsCallingMethodOnNonexistentObject (25034 ms)
[ RUN ] SdbusTestObject/1.CanReceiveSignalWhileMakingMethodCall
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CanReceiveSignalWhileMakingMethodCall, where TypeParam = sdbus::test::SdEventLoop (25034 ms)
[ RUN ] SdbusTestObject/1.CanAccessAssociatedMethodCallMessageInMethodCallHandler
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CanAccessAssociatedMethodCallMessageInMethodCallHandler, where TypeParam = sdbus::test::SdEventLoop (25032 ms)
[ RUN ] SdbusTestObject/1.CanAccessAssociatedMethodCallMessageInAsyncMethodCallHandler
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CanAccessAssociatedMethodCallMessageInAsyncMethodCallHandler, where TypeParam = sdbus::test::SdEventLoop (25032 ms)
[ RUN ] SdbusTestObject/1.CanSetGeneralMethodTimeoutWithLibsystemdVersionGreaterThan239
[ OK ] SdbusTestObject/1.CanSetGeneralMethodTimeoutWithLibsystemdVersionGreaterThan239 (7 ms)
[ RUN ] SdbusTestObject/1.CanCallMethodSynchronouslyWithoutAnEventLoopThread
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CanCallMethodSynchronouslyWithoutAnEventLoopThread, where TypeParam = sdbus::test::SdEventLoop (25034 ms)
[ RUN ] SdbusTestObject/1.EmitsSimpleSignalSuccesfully
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusSignalsTests.cpp:55: Failure
Value of: this->waitUntil(this->m_proxy->m_gotSimpleSignal)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsSimpleSignalSuccesfully, where TypeParam = sdbus::test::SdEventLoop (5081 ms)
[ RUN ] SdbusTestObject/1.EmitsSimpleSignalToMultipleProxiesSuccesfully
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusSignalsTests.cpp:65: Failure
Value of: this->waitUntil(this->m_proxy->m_gotSimpleSignal)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsSimpleSignalToMultipleProxiesSuccesfully, where TypeParam = sdbus::test::SdEventLoop (5088 ms)
[ RUN ] SdbusTestObject/1.ProxyDoesNotReceiveSignalFromOtherBusName
[ OK ] SdbusTestObject/1.ProxyDoesNotReceiveSignalFromOtherBusName (1032 ms)
[ RUN ] SdbusTestObject/1.EmitsSignalWithMapSuccesfully
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusSignalsTests.cpp:85: Failure
Value of: this->waitUntil(this->m_proxy->m_gotSignalWithMap)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsSignalWithMapSuccesfully, where TypeParam = sdbus::test::SdEventLoop (5081 ms)
[ RUN ] SdbusTestObject/1.EmitsSignalWithLargeMapSuccesfully
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusSignalsTests.cpp:97: Failure
Value of: this->waitUntil(this->m_proxy->m_gotSignalWithMap)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsSignalWithLargeMapSuccesfully, where TypeParam = sdbus::test::SdEventLoop (5230 ms)
[ RUN ] SdbusTestObject/1.EmitsSignalWithVariantSuccesfully
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusSignalsTests.cpp:107: Failure
Value of: this->waitUntil(this->m_proxy->m_gotSignalWithVariant)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsSignalWithVariantSuccesfully, where TypeParam = sdbus::test::SdEventLoop (5084 ms)
[ RUN ] SdbusTestObject/1.EmitsSignalWithoutRegistrationSuccesfully
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusSignalsTests.cpp:115: Failure
Value of: this->waitUntil(this->m_proxy->m_gotSignalWithSignature)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsSignalWithoutRegistrationSuccesfully, where TypeParam = sdbus::test::SdEventLoop (5081 ms)
[ RUN ] SdbusTestObject/1.CanAccessAssociatedSignalMessageInSignalHandler
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusSignalsTests.cpp:125: Failure
Value of: this->m_proxy->m_signalMsg
Expected: isn't NULL
Actual: NULL (of type sdbus::Message const*)
[ FAILED ] SdbusTestObject/1.CanAccessAssociatedSignalMessageInSignalHandler, where TypeParam = sdbus::test::SdEventLoop (5080 ms)
[ RUN ] SdbusTestObject/1.UnregistersSignalHandler
[ OK ] SdbusTestObject/1.UnregistersSignalHandler (1026 ms)
[ RUN ] SdbusTestObject/1.UnregistersSignalHandlerForSomeProxies
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusSignalsTests.cpp:147: Failure
Value of: this->waitUntil(proxy1->m_gotSimpleSignal)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.UnregistersSignalHandlerForSomeProxies, where TypeParam = sdbus::test::SdEventLoop (5088 ms)
[ RUN ] SdbusTestObject/1.ReRegistersSignalHandler
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusSignalsTests.cpp:166: Failure
Value of: this->waitUntil(this->m_proxy->m_gotSimpleSignal)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.ReRegistersSignalHandler, where TypeParam = sdbus::test::SdEventLoop (6107 ms)
[ RUN ] SdbusTestObject/1.ReadsReadOnlyPropertySuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.ReadsReadOnlyPropertySuccesfully, where TypeParam = sdbus::test::SdEventLoop (25018 ms)
[ RUN ] SdbusTestObject/1.FailsWritingToReadOnlyProperty
[ OK ] SdbusTestObject/1.FailsWritingToReadOnlyProperty (25024 ms)
[ RUN ] SdbusTestObject/1.WritesAndReadsReadWritePropertySuccesfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.WritesAndReadsReadWritePropertySuccesfully, where TypeParam = sdbus::test::SdEventLoop (25030 ms)
[ RUN ] SdbusTestObject/1.CanAccessAssociatedPropertySetMessageInPropertySetHandler
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.CanAccessAssociatedPropertySetMessageInPropertySetHandler, where TypeParam = sdbus::test::SdEventLoop (25029 ms)
[ RUN ] SdbusTestObject/1.PingsViaPeerInterface
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusStandardInterfacesTests.cpp:57: Failure
Expected: this->m_proxy->Ping() doesn't throw an exception.
Actual: it throws sdbus::Error with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out".
[ FAILED ] SdbusTestObject/1.PingsViaPeerInterface, where TypeParam = sdbus::test::SdEventLoop (25029 ms)
[ RUN ] SdbusTestObject/1.AnswersMachineUuidViaPeerInterface
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusStandardInterfacesTests.cpp:69: Failure
Expected: this->m_proxy->GetMachineId() doesn't throw an exception.
Actual: it throws sdbus::Error with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out".
[ FAILED ] SdbusTestObject/1.AnswersMachineUuidViaPeerInterface, where TypeParam = sdbus::test::SdEventLoop (25009 ms)
[ RUN ] SdbusTestObject/1.GetsPropertyViaPropertiesInterface
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.GetsPropertyViaPropertiesInterface, where TypeParam = sdbus::test::SdEventLoop (25029 ms)
[ RUN ] SdbusTestObject/1.SetsPropertyViaPropertiesInterface
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.SetsPropertyViaPropertiesInterface, where TypeParam = sdbus::test::SdEventLoop (25029 ms)
[ RUN ] SdbusTestObject/1.GetsAllPropertiesViaPropertiesInterface
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.GetsAllPropertiesViaPropertiesInterface, where TypeParam = sdbus::test::SdEventLoop (25029 ms)
[ RUN ] SdbusTestObject/1.EmitsPropertyChangedSignalForSelectedProperties
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.EmitsPropertyChangedSignalForSelectedProperties, where TypeParam = sdbus::test::SdEventLoop (25009 ms)
[ RUN ] SdbusTestObject/1.EmitsPropertyChangedSignalForAllProperties
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusStandardInterfacesTests.cpp:139: Failure
Value of: this->waitUntil(signalReceived)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsPropertyChangedSignalForAllProperties, where TypeParam = sdbus::test::SdEventLoop (5080 ms)
[ RUN ] SdbusTestObject/1.GetsZeroManagedObjectsIfHasNoSubPathObjects
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.GetsZeroManagedObjectsIfHasNoSubPathObjects, where TypeParam = sdbus::test::SdEventLoop (25022 ms)
[ RUN ] SdbusTestObject/1.GetsManagedObjectsSuccessfully
unknown file: Failure
C++ exception with description "[org.freedesktop.DBus.Error.Timeout] Connection timed out" thrown in the test body.
[ FAILED ] SdbusTestObject/1.GetsManagedObjectsSuccessfully, where TypeParam = sdbus::test::SdEventLoop (25033 ms)
[ RUN ] SdbusTestObject/1.EmitsInterfacesAddedSignalForSelectedObjectInterfaces
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusStandardInterfacesTests.cpp:192: Failure
Value of: this->waitUntil(signalReceived)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsInterfacesAddedSignalForSelectedObjectInterfaces, where TypeParam = sdbus::test::SdEventLoop (5082 ms)
[ RUN ] SdbusTestObject/1.EmitsInterfacesAddedSignalForAllObjectInterfaces
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusStandardInterfacesTests.cpp:228: Failure
Value of: this->waitUntil(signalReceived)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsInterfacesAddedSignalForAllObjectInterfaces, where TypeParam = sdbus::test::SdEventLoop (5082 ms)
[ RUN ] SdbusTestObject/1.EmitsInterfacesRemovedSignalForSelectedObjectInterfaces
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusStandardInterfacesTests.cpp:245: Failure
Value of: this->waitUntil(signalReceived)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsInterfacesRemovedSignalForSelectedObjectInterfaces, where TypeParam = sdbus::test::SdEventLoop (5081 ms)
[ RUN ] SdbusTestObject/1.EmitsInterfacesRemovedSignalForAllObjectInterfaces
/usr/src/debug/sdbus-c++/2.0.0.0-r0/git/tests/integrationtests/DBusStandardInterfacesTests.cpp:267: Failure
Value of: this->waitUntil(signalReceived)
Actual: false
Expected: true
[ FAILED ] SdbusTestObject/1.EmitsInterfacesRemovedSignalForAllObjectInterfaces, where TypeParam = sdbus::test::SdEventLoop (5081 ms)
[----------] 55 tests from SdbusTestObject/1 (911014 ms total)
[----------] 11 tests from AsyncSdbusTestObject/0, where TypeParam = sdbus::test::SdBusCppLoop
[ RUN ] AsyncSdbusTestObject/0.ThrowsTimeoutErrorWhenClientSideAsyncMethodTimesOut
[ OK ] AsyncSdbusTestObject/0.ThrowsTimeoutErrorWhenClientSideAsyncMethodTimesOut (6 ms)
[ RUN ] AsyncSdbusTestObject/0.RunsServerSideAsynchoronousMethodAsynchronously
[ OK ] AsyncSdbusTestObject/0.RunsServerSideAsynchoronousMethodAsynchronously (1586 ms)
[ RUN ] AsyncSdbusTestObject/0.HandlesCorrectlyABulkOfParallelServerSideAsyncMethods
[ OK ] AsyncSdbusTestObject/0.HandlesCorrectlyABulkOfParallelServerSideAsyncMethods (1122 ms)
[ RUN ] AsyncSdbusTestObject/0.InvokesMethodAsynchronouslyOnClientSide
[ OK ] AsyncSdbusTestObject/0.InvokesMethodAsynchronouslyOnClientSide (111 ms)
[ RUN ] AsyncSdbusTestObject/0.AnswersThatAsyncCallIsPendingIfItIsInProgress
[ OK ] AsyncSdbusTestObject/0.AnswersThatAsyncCallIsPendingIfItIsInProgress (7 ms)
[ RUN ] AsyncSdbusTestObject/0.CancelsPendingAsyncCallOnClientSide
[ OK ] AsyncSdbusTestObject/0.CancelsPendingAsyncCallOnClientSide (308 ms)
[ RUN ] AsyncSdbusTestObject/0.AnswersThatAsyncCallIsNotPendingAfterItHasBeenCancelled
[ OK ] AsyncSdbusTestObject/0.AnswersThatAsyncCallIsNotPendingAfterItHasBeenCancelled (108 ms)
[ RUN ] AsyncSdbusTestObject/0.AnswersThatAsyncCallIsNotPendingAfterItHasBeenCompleted
[ OK ] AsyncSdbusTestObject/0.AnswersThatAsyncCallIsNotPendingAfterItHasBeenCompleted (12 ms)
[ RUN ] AsyncSdbusTestObject/0.AnswersThatDefaultConstructedAsyncCallIsNotPending
[ OK ] AsyncSdbusTestObject/0.AnswersThatDefaultConstructedAsyncCallIsNotPending (7 ms)
[ RUN ] AsyncSdbusTestObject/0.SupportsAsyncCallCopyAssignment
[ OK ] AsyncSdbusTestObject/0.SupportsAsyncCallCopyAssignment (7 ms)
[ RUN ] AsyncSdbusTestObject/0.InvokesErroneousMethodAsynchronouslyOnClientSide
[ OK ] AsyncSdbusTestObject/0.InvokesErroneousMethodAsynchronouslyOnClientSide (8 ms)
[----------] 11 tests from AsyncSdbusTestObject/0 (3290 ms total)
[----------] 11 tests from AsyncSdbusTestObject/1, where TypeParam = sdbus::test::SdEventLoop
[ RUN ] AsyncSdbusTestObject/1.ThrowsTimeoutErrorWhenClientSideAsyncMethodTimesOut
^C
If I do a strace, I can see the same error there:
strace -ff -e timerfd_settime ./sdbus-c++-integration-tests --gtest_filter=SdbusTestObject/1.CallsEmptyMethodSuccesfully --gtest_brief=1
strace: Process 1411 attached
strace: Process 1412 attached
[pid 1411] timerfd_settime(11, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=-1, tv_nsec=4294967295}}, NULL) = -1 EINVAL (Invalid argument)
[pid 1412] timerfd_settime(12, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=-1, tv_nsec=4294967295}}, NULL) = -1 EINVAL (Invalid argument)
[pid 1411] +++ exited with 0 +++
[pid 1412] +++ exited with 0 +++
^Cstrace: Process 1410 detached
On my x86_64 all the tests work fine. Interesting enough there's no call to timerfd_settime
at all!
strace -ff tests/sdbus-c++-integration-tests --gtest_filter=SdbusTestObject.CallsEmptyMethodSuccesfully --gtest_brief=1 2&| rg -i time
The systemd version is also the same:
arm:
systemctl --version
systemd 249 (249.7+)
+PAM -AUDIT -SELINUX -APPARMOR +IMA -SMACK +SECCOMP -GCRYPT -GNUTLS -OPENSSL +ACL +BLKID -CURL -ELFUTILS -FIDO2 -IDN2 -IDN -IPTC +KMOD -LIBCRYPTSETUP +LIBFDISK -PCRE2 -PWQUALITY -P11KIT -QRENCODE -BZIP2 -LZ4 -XZ -ZLIB +ZSTD -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=hybrid
x86:
systemctl --version
systemd 249 (249.11-0ubuntu3.9)
+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY -P11KIT -QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified
Interesting. I was about to ask about systemd version but now I read it's the same... So perhaps it could be something with target system/architecture, and also the question is whether this is an issue of systemd or sdbus-c++ itself. I may look at the former tomorrow as I'll have ARM-based (probably armv8a, however) device on my desk.
Could you please look at the later? I.e. extract the minimal example to make it fail and write that example using systemd sd-bus API, using sd_bus_attach_event
.
Thanks a lot 👍
If that sd-bus example fails too, then this is the matter of systemd and we will need to go systemd mailing list to ask for help.
Something to note is that man 2 timerfd says:
timerfd_settime()
can also fail with the following errors:
EINVAL
new_value
is not properly initialized (one of thetv_nsec
falls outside the range zero to 999,999,999).
and the value is certainly not in that range:
[pid 1411] timerfd_settime(11, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=-1, tv_nsec=4294967295}}, NULL) = -1 EINVAL (Invalid argument)
The question remains the same, is that an sdbus-cpp fault or systemds.
I reproduced this on my ARMv7-A-based device (I also tried on 64-bit ARM v8-A, but that one works fine). Have you managed to isolate a minimalist example to see if it's a libsystemd or sdbus-c++ issue?
pretty minimal, eh?
int main(int argc, char** argv) {
sd_event* ev;
sd_event_new(&ev);
sd_bus* bus = NULL;
sd_bus_default(&bus);
sd_bus_attach_event(bus, ev, 0);
// auto bus = sdbus::createConnection();
// bus->attachSdEventLoop(ev);
sd_event_loop(ev);
return 0;
}
with sd_bus
:
# strace -e timerfd_settime ~/foo-foo
timerfd_settime(5, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=15805, tv_nsec=992759000}}, NULL) = 0
timerfd_settime(5, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=15740, tv_nsec=992759000}}, NULL) = 0
timerfd_settime(5, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=0, tv_nsec=0}}, NULL) = 0
^C
with sdbus-cpp
:
# strace -e timerfd_settime ~/foo-foo
timerfd_settime(7, TFD_TIMER_ABSTIME, {it_interval={tv_sec=0, tv_nsec=0}, it_value={tv_sec=-1, tv_nsec=4294967295}}, NULL) = -1 EINVAL (Invalid argument)
+++ exited with 0 +++
I think the problem is in the sd_bus_get_timeout
function which is called inside the getEventLoopPollData
here
Lines 364 to 389 in 9cc74e9
According to the docs:
sd_bus_get_timeout()
returns the timeout in µs to pass topoll()
or a similar call when waiting for events on the specified bus
connection. The returned timeout may be zero, in which case a
subsequent I/O polling call should be invoked in non-blocking
mode. The returned timeout may beUINT64_MAX
in which case the
I/O polling call may block indefinitely, without any applied
timeout.
The highlighted paragraph is exactly what we are seeing. A call to timerfd_settime
with -1
as argument.
We may set the tv_sec
of the struct timespec
to a large value, but tv_nsec
should be 0.
strip that, sdbus is doing the same thing.
I currently do not have the capability to investigate this further, but you may be able? At least you can reproduce the issue, that's something! :)
I'll try to do some more stuff here, but I don't have time for that right now... sorry :\
No problem, thanks much for the analysis, I'll take up on that
I think I found it:
It seems, that sdbus uses an undocumented return value to decide whether to install an timer or not:
r = sd_bus_get_timeout(bus, &until);
if (r < 0)
goto fail;
if (r > 0) {
please note, that the code specifically excludes the return value of 0
.
0
is returned, when sd_bus_get_timeout
returns 0xFFFFFFFFFFFFFFFF
or UINT64_MAX
.
However, this is not documented and I don't think we should rely on that. Instead I suggest to check for UINT64_MAX
, respectively INT64_MAX
, since the timeout get's overwritten here
Line 144 in 9cc74e9
So, I suggest adding an if
guard like this:
if (sdbusPollData.timeout.count() != INT64_MAX) {
auto* sdTimeEventSource = static_cast<sd_event_source*>(connection->sdEvent_->sdTimeEventSource.get());
r = sd_event_source_set_time(sdTimeEventSource, static_cast<uint64_t>(sdbusPollData.timeout.count()));
SDBUS_THROW_ERROR_IF(r < 0, "Failed to set timeout for time event source", -r);
r = sd_event_source_set_enabled(sdTimeEventSource, SD_EVENT_ON);
SDBUS_THROW_ERROR_IF(r < 0, "Failed to enable time event source", -r);
}
I submitted an PR that does this, please feel free to comment on that.