Skip to content

Commit

Permalink
iox-#2121 Fix history request is out of limit.
Browse files Browse the repository at this point in the history
History request may be larger than queue capacity if queue capacity
larger than MAX_QUEUE_CAPACITY during creating a subscriber. The fix
clamps the history request to clamped queue capacity.

Signed-off-by: Xuebing Wang <[email protected]>
  • Loading branch information
Xuebing Wang committed Nov 28, 2023
1 parent f0622f1 commit 787f6fb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
- Chunk fails to be released when more than 4 GiB of chunks have been allocated [#2087](https://github.com/eclipse-iceoryx/iceoryx/issues/2087)
- Fix clang-tidy errors from full-scan nightly build [#2060](https://github.com/eclipse-iceoryx/iceoryx/issues/2060)
- Add public functions to create an 'access_rights' object from integer values [#2108](https://github.com/eclipse-iceoryx/iceoryx/issues/2108)
- Fix `historyRequest` may be larger than `queueCapacity` during creating a subscriber [#2121](https://github.com/eclipse-iceoryx/iceoryx/issues/2121)

**Refactoring:**

Expand Down
4 changes: 2 additions & 2 deletions iceoryx_posh/source/runtime/posh_runtime_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ PoshRuntimeImpl::getMiddlewareSubscriber(const capro::ServiceDescription& servic
options.queueCapacity = 1U;
}

if (subscriberOptions.historyRequest > subscriberOptions.queueCapacity)
if (subscriberOptions.historyRequest > options.queueCapacity)
{
IOX_LOG(WARN,
"Requested historyRequest for "
<< service << " is larger than queueCapacity. Clamping historyRequest to queueCapacity!");
options.historyRequest = subscriberOptions.queueCapacity;
options.historyRequest = options.queueCapacity;
}

if (options.nodeName.empty())
Expand Down
16 changes: 16 additions & 0 deletions iceoryx_posh/test/moduletests/test_posh_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,22 @@ TEST_F(PoshRuntime_test, GetMiddlewareSubscriberWithHistoryRequestLargerThanQueu
EXPECT_EQ(EXPECTED_HISTORY_REQUEST, subscriberPort->m_options.historyRequest);
}


TEST_F(PoshRuntime_test,
GetMiddlewareSubscriberWithHistoryRequestLargerThanClampedQueueCapacityClampsToClampedQueueCapacity)
{
::testing::Test::RecordProperty("TEST_ID", "9746468f-d191-43d9-b973-542fa8a66101");
iox::popo::SubscriberOptions subscriberOptions;
constexpr uint64_t MAX_QUEUE_CAPACITY = iox::popo::SubscriberPortUser::MemberType_t::ChunkQueueData_t::MAX_CAPACITY;
subscriberOptions.queueCapacity = MAX_QUEUE_CAPACITY + 1;
subscriberOptions.historyRequest = MAX_QUEUE_CAPACITY + 2;

auto subscriberPort = m_runtime->getMiddlewareSubscriber(
iox::capro::ServiceDescription("91", "1", "2"), subscriberOptions, iox::runtime::PortConfigInfo(33U, 11U, 22U));

EXPECT_EQ(MAX_QUEUE_CAPACITY, subscriberPort->m_options.queueCapacity);
EXPECT_EQ(MAX_QUEUE_CAPACITY, subscriberPort->m_options.historyRequest);
}
TEST_F(PoshRuntime_test, GetMiddlewareSubscriberDefaultArgs)
{
::testing::Test::RecordProperty("TEST_ID", "e06b999c-e237-4e32-b826-a5ffdb6bb737");
Expand Down

0 comments on commit 787f6fb

Please sign in to comment.