Skip to content

Commit 59f3c91

Browse files
muhsethfbaeuerle
authored andcommitted
Revert "lola: add QNX8 workaround for poll"
This reverts commit d66494f9b7c79e91d112a4c1eee5d9dad9a85c4e. GIT_ORIGIN_SPP_REV_ID: d392720ef0461adb7745fbd42e7ee7feff946cf6
1 parent 3e17582 commit 59f3c91

File tree

1 file changed

+25
-46
lines changed

1 file changed

+25
-46
lines changed

score/os/utils/abortable_blocking_reader.cpp

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -208,23 +208,22 @@ score::cpp::expected<score::cpp::span<std::uint8_t>, Error> AbortableBlockingRea
208208
return score::cpp::make_unexpected(Error::createFromErrno(EINVAL));
209209
}
210210

211-
// Wait until data is available (or timeout/abort). This function loops internally on QNX8.
212-
const auto wait_status = WaitForData(file_descriptor);
213-
if (!wait_status.has_value())
211+
const auto data_available = WaitForData(file_descriptor);
212+
213+
if (!data_available.has_value())
214214
{
215-
return score::cpp::make_unexpected(wait_status.error());
215+
return score::cpp::make_unexpected(data_available.error());
216216
}
217217

218218
// Suppressed here as it is safely used:
219219
// Provided error check and safeguard to ensure file descriptor is valid before reading.
220220
// NOLINTNEXTLINE(score-banned-function) see comment above
221-
const auto read_result = unistd_->read(file_descriptor, buffer.data(), buffer.size());
222-
if ((!read_result.has_value()) || (read_result.value() < 0))
221+
const auto expected_length = unistd_->read(file_descriptor, buffer.data(), buffer.size());
222+
if ((!expected_length.has_value()) || (expected_length.value() < 0))
223223
{
224-
return score::cpp::make_unexpected(read_result.error());
224+
return score::cpp::make_unexpected(expected_length.error());
225225
}
226-
227-
return buffer.first(static_cast<std::size_t>(read_result.value()));
226+
return buffer.first(static_cast<std::size_t>(expected_length.value()));
228227
}
229228

230229
void AbortableBlockingReader::SignalStop() noexcept
@@ -250,57 +249,37 @@ score::cpp::expected_blank<Error> AbortableBlockingReader::WaitForData(
250249
const NonBlockingFileDescriptor& file_descriptor) noexcept
251250
{
252251
std::array<struct pollfd, 2> fds{};
253-
254-
#ifdef __QNXNTO__
255-
// QNX8 workaround until Ticket-221150 is resolved : add finite timeout so we don't sleep forever if the
256-
// resource manager fails to wake pollers; keep true blocking elsewhere.
257-
constexpr std::int8_t kPollTimeoutMs = 50; // tuneable: 10–100 ms
258-
#else
259-
constexpr std::int8_t kPollTimeoutMs = -1; // infinite blocking on other OSes
260-
#endif
252+
constexpr std::int8_t kNoTimeout{-1};
261253

262254
fds[0].fd = stop_read_file_descriptor_;
263255
// Suppress "AUTOSAR C++14 M5-0-21" rule findings. This rule declares: "Bitwise operators shall only be
264256
// applied to operands of unsigned underlying type."
265257
// Rationale: Macro POLLIN does not affect the sign of the result.
266258
// coverity[autosar_cpp14_m5_0_21_violation]
267-
fds[0].events = POLLIN; // self-pipe for abort
259+
fds[0].events = POLLIN;
268260

269261
fds[1].fd = file_descriptor.GetUnderlying();
270-
// QNX8 often reports only POLLRDNORM for readable inotify fds.
271262
// Rationale: see comment above
272263
// coverity[autosar_cpp14_m5_0_21_violation]
273-
fds[1].events = (POLLIN | POLLRDNORM);
274-
275-
while (true)
276-
{
277-
// coverity[autosar_cpp14_m5_0_6_violation]
278-
const auto poll_result = syspoll_->poll(fds.data(), fds.size(), kPollTimeoutMs);
264+
fds[1].events = POLLIN;
279265

280-
if (!poll_result.has_value())
281-
{
282-
return score::cpp::make_unexpected(poll_result.error());
283-
}
266+
// coverity[autosar_cpp14_m5_0_6_violation]
267+
const auto poll_result = syspoll_->poll(fds.data(), fds.size(), kNoTimeout);
284268

285-
// Check return event flag for stop_read_file_descriptor_
286-
// Rationale: see comment above
287-
// coverity[autosar_cpp14_m5_0_21_violation]
288-
if ((static_cast<std::uint32_t>(fds[0].revents) & static_cast<std::uint32_t>(POLLIN)) != 0U)
289-
{
290-
return score::cpp::make_unexpected(Error::createFromErrno(EINTR));
291-
}
292-
293-
// If the watched fd is readable, we're ready; otherwise it was a timeout/spurious wake.
294-
// Rationale: see comment above
295-
// coverity[autosar_cpp14_m5_0_21_violation]
296-
if ((static_cast<std::uint32_t>(fds[1].revents) &
297-
(static_cast<std::uint32_t>(POLLIN) | static_cast<std::uint32_t>(POLLRDNORM))) != 0U)
298-
{
299-
return {};
300-
}
269+
if (!poll_result.has_value())
270+
{
271+
return score::cpp::make_unexpected(poll_result.error());
272+
}
301273

302-
// No event yet — timeout or spurious wake. Loop again (QNX8 workaround).
274+
// Check return event flag for stop_read_file_descriptor_
275+
// Rationale: see comment above
276+
// coverity[autosar_cpp14_m5_0_21_violation]
277+
if ((static_cast<std::uint32_t>(fds[0].revents) & static_cast<std::uint32_t>(POLLIN)) != 0U)
278+
{
279+
return score::cpp::make_unexpected(Error::createFromErrno(EINTR));
303280
}
281+
282+
return {};
304283
}
305284

306285
score::cpp::expected<std::pair<NonBlockingFileDescriptor, NonBlockingFileDescriptor>, Error>

0 commit comments

Comments
 (0)