IPC: QSystemSemaphore/SystemV: move up the check for handle
This avoids recalculating the native key file name every time we call handle() to ensure the handle exists. The POSIX backend already has the code like this (whence the comment was copied) and the Win32 backend is similar. Change-Id: Idd5e1bb52be047d7b4fffffd175076ec09334ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
bc99f84478
commit
6a4901db25
@ -53,6 +53,9 @@ bool QSystemSemaphoreSystemV::runtimeSupportCheck()
|
||||
*/
|
||||
key_t QSystemSemaphoreSystemV::handle(QSystemSemaphorePrivate *self, QSystemSemaphore::AccessMode mode)
|
||||
{
|
||||
if (unix_key != -1)
|
||||
return unix_key; // we already have a semaphore
|
||||
|
||||
#if defined(Q_OS_DARWIN)
|
||||
if (qt_apple_isSandboxed()) {
|
||||
// attempting to use System V semaphores will get us a SIGSYS
|
||||
@ -73,9 +76,6 @@ key_t QSystemSemaphoreSystemV::handle(QSystemSemaphorePrivate *self, QSystemSema
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (-1 != unix_key)
|
||||
return unix_key;
|
||||
|
||||
// ftok requires that an actual file exists somewhere
|
||||
int built = QtIpcCommon::createUnixKeyFile(nativeKeyFile);
|
||||
if (-1 == built) {
|
||||
|
Loading…
Reference in New Issue
Block a user