diff --git a/iceoryx_binding_c/test/moduletests/test_listener.cpp b/iceoryx_binding_c/test/moduletests/test_listener.cpp index b6ba72b3ed..58ae7deaa4 100644 --- a/iceoryx_binding_c/test/moduletests/test_listener.cpp +++ b/iceoryx_binding_c/test/moduletests/test_listener.cpp @@ -441,7 +441,7 @@ void notifyClient(ClientPortData& portData) portData.m_connectionState = iox::ConnectionState::CONNECTED; iox::popo::ChunkQueuePusher pusher{&portData.m_chunkReceiverData}; pusher.push(iox::mepoo::SharedChunk()); - EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error()); + EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error()); } TIMING_TEST_F(iox_listener_test, NotifyingClientEventWorks, Repeat(5), [&] { @@ -491,7 +491,7 @@ void notifyServer(ServerPortData& portData) { iox::popo::ChunkQueuePusher pusher{&portData.m_chunkReceiverData}; pusher.push(iox::mepoo::SharedChunk()); - EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error()); + EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error()); } TEST_F(iox_listener_test, AttachingServerWorks) diff --git a/iceoryx_binding_c/test/moduletests/test_wait_set.cpp b/iceoryx_binding_c/test/moduletests/test_wait_set.cpp index 87b0a83004..07f6c39767 100644 --- a/iceoryx_binding_c/test/moduletests/test_wait_set.cpp +++ b/iceoryx_binding_c/test/moduletests/test_wait_set.cpp @@ -796,7 +796,7 @@ void notifyClient(ClientPortData& portData) portData.m_connectionState = iox::ConnectionState::CONNECTED; iox::popo::ChunkQueuePusher pusher{&portData.m_chunkReceiverData}; pusher.push(iox::mepoo::SharedChunk()); - EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error()); + EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error()); } TEST_F(iox_ws_test, NotifyingClientEventWorks) @@ -928,7 +928,7 @@ void notifyServer(ServerPortData& portData) { iox::popo::ChunkQueuePusher pusher{&portData.m_chunkReceiverData}; pusher.push(iox::mepoo::SharedChunk()); - EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error()); + EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error()); } TEST_F(iox_ws_test, AttachingServerEventWorks) @@ -1140,7 +1140,7 @@ void notifyServiceDiscovery(SubscriberPortData& portData) { iox::popo::ChunkQueuePusher pusher{&portData.m_chunkReceiverData}; pusher.push(iox::mepoo::SharedChunk()); - EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error()); + EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error()); } TEST_F(iox_ws_test, NotifyingServiceDiscoveryEventWorks) diff --git a/iceoryx_examples/request_response_in_c/client_c_waitset.c b/iceoryx_examples/request_response_in_c/client_c_waitset.c index 5c6e8df157..0c53e79905 100644 --- a/iceoryx_examples/request_response_in_c/client_c_waitset.c +++ b/iceoryx_examples/request_response_in_c/client_c_waitset.c @@ -27,6 +27,7 @@ #include #include #include +#include #define NUMBER_OF_NOTIFICATIONS 1 diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/functional_interface.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/functional_interface.hpp index e83d4f501e..a3f759da41 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/functional_interface.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/functional_interface.hpp @@ -21,7 +21,6 @@ #include "iceoryx_hoofs/cxx/type_traits.hpp" #include "iceoryx_hoofs/platform/unistd.hpp" -#include #include namespace iox diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_pipe.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_pipe.hpp index b8a7dd6b0c..72ba6e83c9 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_pipe.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_pipe.hpp @@ -38,9 +38,8 @@ class NamedPipe : public DesignPattern::Creation // increased as long as there is enough memory available static constexpr uint64_t MAX_MESSAGE_SIZE = 4U * 1024U; static constexpr uint32_t MAX_NUMBER_OF_MESSAGES = 10U; - static_assert( - MAX_NUMBER_OF_MESSAGES < IOX_SEM_VALUE_MAX, - "The maximum number of supported messages must be less or equal to the maximum allowed semaphore value"); + static_assert(MAX_NUMBER_OF_MESSAGES < IOX_SEM_VALUE_MAX, + "The maximum number of supported messages must be less to the maximum allowed semaphore value"); static constexpr uint64_t NULL_TERMINATOR_SIZE = 0U; static constexpr units::Duration CYCLE_TIME = units::Duration::fromMilliseconds(10); diff --git a/iceoryx_hoofs/source/posix_wrapper/signal_watcher.cpp b/iceoryx_hoofs/source/posix_wrapper/signal_watcher.cpp index 69eb2f4547..bc74599e69 100644 --- a/iceoryx_hoofs/source/posix_wrapper/signal_watcher.cpp +++ b/iceoryx_hoofs/source/posix_wrapper/signal_watcher.cpp @@ -35,8 +35,9 @@ void internalSignalHandler(int) noexcept // we use write since internalSignalHandler can be called from within a // signal handler and write is signal safe constexpr const char MSG[] = "Unable to increment semaphore in signal handler"; - auto result = write(STDERR_FILENO, &MSG[0], strlen(&MSG[0])); + auto result = write(STDERR_FILENO, MSG, strlen(MSG)); IOX_DISCARD_RESULT(result); + std::abort(); } } } diff --git a/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/watch_dog.hpp b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/watch_dog.hpp index c722f1d707..7d922f923c 100644 --- a/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/watch_dog.hpp +++ b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/watch_dog.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_listener.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_listener.hpp index 0e3ff5c027..22eac79490 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_listener.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_listener.hpp @@ -69,7 +69,7 @@ class ConditionListener ConditionVariableData* getMembers() noexcept; private: - void reset(const uint64_t index) noexcept; + void resetUnchecked(const uint64_t index) noexcept; void resetSemaphore() noexcept; NotificationVector_t waitImpl(const cxx::function_ref& waitCall) noexcept; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp index b3f106258f..e44ab6e910 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ struct ConditionVariableData ConditionVariableData& operator=(ConditionVariableData&& rhs) = delete; ~ConditionVariableData() noexcept = default; - cxx::optional semaphore; + cxx::optional m_semaphore; RuntimeName_t m_runtimeName; std::atomic_bool m_toBeDestroyed{false}; std::atomic_bool m_activeNotifications[MAX_NUMBER_OF_NOTIFIERS]; diff --git a/iceoryx_posh/source/popo/building_blocks/condition_listener.cpp b/iceoryx_posh/source/popo/building_blocks/condition_listener.cpp index 8c01d2c1af..6b0fc5d6cf 100644 --- a/iceoryx_posh/source/popo/building_blocks/condition_listener.cpp +++ b/iceoryx_posh/source/popo/building_blocks/condition_listener.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ void ConditionListener::resetSemaphore() noexcept bool hasFatalError = false; while (!hasFatalError && getMembers() - ->semaphore->tryWait() + ->m_semaphore->tryWait() .or_else([&](posix::SemaphoreError) { errorHandler(PoshError::POPO__CONDITION_LISTENER_SEMAPHORE_CORRUPTED_IN_RESET, ErrorLevel::FATAL); hasFatalError = true; @@ -46,7 +46,7 @@ void ConditionListener::resetSemaphore() noexcept void ConditionListener::destroy() noexcept { m_toBeDestroyed.store(true, std::memory_order_relaxed); - getMembers()->semaphore->post().or_else([](auto) { + getMembers()->m_semaphore->post().or_else([](auto) { errorHandler(PoshError::POPO__CONDITION_LISTENER_SEMAPHORE_CORRUPTED_IN_DESTROY, ErrorLevel::FATAL); }); } @@ -59,7 +59,7 @@ bool ConditionListener::wasNotified() const noexcept ConditionListener::NotificationVector_t ConditionListener::wait() noexcept { return waitImpl([this]() -> bool { - if (this->getMembers()->semaphore->wait().has_error()) + if (this->getMembers()->m_semaphore->wait().has_error()) { errorHandler(PoshError::POPO__CONDITION_LISTENER_SEMAPHORE_CORRUPTED_IN_WAIT, ErrorLevel::FATAL); return false; @@ -71,7 +71,7 @@ ConditionListener::NotificationVector_t ConditionListener::wait() noexcept ConditionListener::NotificationVector_t ConditionListener::timedWait(const units::Duration& timeToWait) noexcept { return waitImpl([this, timeToWait]() -> bool { - if (this->getMembers()->semaphore->timedWait(timeToWait).has_error()) + if (this->getMembers()->m_semaphore->timedWait(timeToWait).has_error()) { errorHandler(PoshError::POPO__CONDITION_LISTENER_SEMAPHORE_CORRUPTED_IN_TIMED_WAIT, ErrorLevel::FATAL); } @@ -92,7 +92,7 @@ ConditionListener::NotificationVector_t ConditionListener::waitImpl(const cxx::f { if (getMembers()->m_activeNotifications[i].load(std::memory_order_relaxed)) { - reset(i); + resetUnchecked(i); activeNotifications.emplace_back(i); } } @@ -107,7 +107,7 @@ ConditionListener::NotificationVector_t ConditionListener::waitImpl(const cxx::f return activeNotifications; } -void ConditionListener::reset(const uint64_t index) noexcept +void ConditionListener::resetUnchecked(const uint64_t index) noexcept { getMembers()->m_activeNotifications[index].store(false, std::memory_order_relaxed); getMembers()->m_wasNotified.store(false, std::memory_order_relaxed); diff --git a/iceoryx_posh/source/popo/building_blocks/condition_notifier.cpp b/iceoryx_posh/source/popo/building_blocks/condition_notifier.cpp index 2a7fdf3ded..cca8cff7cb 100644 --- a/iceoryx_posh/source/popo/building_blocks/condition_notifier.cpp +++ b/iceoryx_posh/source/popo/building_blocks/condition_notifier.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ void ConditionNotifier::notify() noexcept { getMembers()->m_activeNotifications[m_notificationIndex].store(true, std::memory_order_release); getMembers()->m_wasNotified.store(true, std::memory_order_relaxed); - getMembers()->semaphore->post().or_else( + getMembers()->m_semaphore->post().or_else( [](auto) { errorHandler(PoshError::POPO__CONDITION_NOTIFIER_SEMAPHORE_CORRUPT_IN_NOTIFY, ErrorLevel::FATAL); }); } diff --git a/iceoryx_posh/source/popo/building_blocks/condition_variable_data.cpp b/iceoryx_posh/source/popo/building_blocks/condition_variable_data.cpp index dabbc2c813..e1793c0de9 100644 --- a/iceoryx_posh/source/popo/building_blocks/condition_variable_data.cpp +++ b/iceoryx_posh/source/popo/building_blocks/condition_variable_data.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2020 - 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ ConditionVariableData::ConditionVariableData() noexcept ConditionVariableData::ConditionVariableData(const RuntimeName_t& runtimeName) noexcept : m_runtimeName(runtimeName) { - posix::UnnamedSemaphoreBuilder().initialValue(0U).isInterProcessCapable(true).create(semaphore).or_else([](auto) { + posix::UnnamedSemaphoreBuilder().initialValue(0U).isInterProcessCapable(true).create(m_semaphore).or_else([](auto) { errorHandler(PoshError::POPO__CONDITION_VARIABLE_DATA_FAILED_TO_CREATE_SEMAPHORE, ErrorLevel::FATAL); }); diff --git a/iceoryx_posh/test/moduletests/test_popo_condition_variable.cpp b/iceoryx_posh/test/moduletests/test_popo_condition_variable.cpp index 5ebdd0ff6a..b0c1dc065c 100644 --- a/iceoryx_posh/test/moduletests/test_popo_condition_variable.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_condition_variable.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.