From 03ef30d97502e692556924315e149122b9f981ea Mon Sep 17 00:00:00 2001 From: Krzysztof Sommerfeld Date: Wed, 6 Dec 2023 23:12:20 +0100 Subject: [PATCH] Recreate posix QSystemSemaphore on release for VxWorks `QSystemSemaphore` used by `QSharedMemory` class, when failed to acquire native sem by calling `sem_wait`, will check the reason of failure and if it is because the semaphore is no longer valid (destroyed by some other `QSharedMemory` object accessing the same data) will recreate it and repeat. However, the same is not done when `QSystemSemaphore` is calling release. Add this functionality also for release. Task-number: QTBUG-115777 Pick-to: 6.7 Change-Id: Ic5d2438c93db318b993becff930b480fd3177532 Reviewed-by: Thiago Macieira --- src/corelib/ipc/qsystemsemaphore_posix.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/ipc/qsystemsemaphore_posix.cpp b/src/corelib/ipc/qsystemsemaphore_posix.cpp index 0de59e219a..7df9593513 100644 --- a/src/corelib/ipc/qsystemsemaphore_posix.cpp +++ b/src/corelib/ipc/qsystemsemaphore_posix.cpp @@ -126,6 +126,12 @@ bool QSystemSemaphorePosix::modifySemaphore(QSystemSemaphorePrivate *self, int c int cnt = count; do { if (::sem_post(semaphore) == -1) { +#if defined(Q_OS_VXWORKS) + if (errno == EINVAL) { + semaphore = SEM_FAILED; + return modifySemaphore(self, cnt); + } +#endif self->setUnixErrorString("QSystemSemaphore::modifySemaphore (sem_post)"_L1); #if defined QSYSTEMSEMAPHORE_DEBUG qDebug("QSystemSemaphorePosix::modify sem_post failed %d %d", count, errno);