summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <qt-info@nokia.com>2010-04-19 06:58:24 (GMT)
committerAndy Shaw <qt-info@nokia.com>2010-04-19 06:58:24 (GMT)
commit73a1291a3f097787f00d79d0d27bd75219bf8e3d (patch)
tree6e9a633e916d72408581e21d2d088d5534964389 /src
parentee6483a76e62a69641530f36ad35f1f686914442 (diff)
downloadQt-73a1291a3f097787f00d79d0d27bd75219bf8e3d.zip
Qt-73a1291a3f097787f00d79d0d27bd75219bf8e3d.tar.gz
Qt-73a1291a3f097787f00d79d0d27bd75219bf8e3d.tar.bz2
Report the error as being AlreadyExists if this is why it fails
On Windows it would never report this error, and on Unix it would report a different error ulimately instead as it tried to obtain the semaphore a second time which could cause a different error to what should be reported. Task-number: QTBUG-9610 Reviewed-by: Frans Englich
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qsystemsemaphore_unix.cpp2
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp8
2 files changed, 7 insertions, 3 deletions
diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp
index 07e3618..d6c6c37 100644
--- a/src/corelib/kernel/qsystemsemaphore_unix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp
@@ -145,10 +145,10 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
// Get semaphore
semaphore = semget(unix_key, 1, 0666 | IPC_CREAT | IPC_EXCL);
if (-1 == semaphore) {
+ setErrorString(QLatin1String("QSystemSemaphore::handle"));
if (errno == EEXIST)
semaphore = semget(unix_key, 1, 0666 | IPC_CREAT);
if (-1 == semaphore) {
- setErrorString(QLatin1String("QSystemSemaphore::handle"));
cleanHandle();
return -1;
}
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index 96a47f5..74f253a 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -69,6 +69,10 @@ void QSystemSemaphorePrivate::setErrorString(const QString &function)
error = QSystemSemaphore::PermissionDenied;
errorString = QCoreApplication::translate("QSystemSemaphore", "%1: permission denied").arg(function);
break;
+ case ERROR_ALREADY_EXISTS:
+ error = QSystemSemaphore::AlreadyExists;
+ errorString = QCoreApplication::translate("QSystemSemaphore", "%1: already exists").arg(function);
+ break;
default:
errorString = QCoreApplication::translate("QSystemSemaphore", "%1: unknown error %2").arg(function).arg(windowsError);
error = QSystemSemaphore::UnknownError;
@@ -88,8 +92,8 @@ HANDLE QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode)
if (semaphore == 0) {
QString safeName = makeKeyFileName();
semaphore = CreateSemaphore(0, initialValue, MAXLONG, (wchar_t*)safeName.utf16());
- if (semaphore == NULL)
- setErrorString(QLatin1String("QSystemSemaphore::handle"));
+ // If the semaphore exists then the handle is still valid but there is still an error
+ setErrorString(QLatin1String("QSystemSemaphore::handle"));
}
return semaphore;