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 <thiago.macieira@intel.com>
bb10
Krzysztof Sommerfeld 2023-12-06 23:12:20 +01:00
parent 9d8473cdf6
commit 03ef30d975
1 changed files with 6 additions and 0 deletions

View File

@ -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);