diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2011-06-01 14:49:39 (GMT) |
---|---|---|
committer | Harald Fernengel <harald.fernengel@nokia.com> | 2011-06-01 14:49:39 (GMT) |
commit | b840d8255196241fa7c2684c0443471330f94046 (patch) | |
tree | dbcc7c6a23f00306c375cb8f61bf05317d880b2a /src/gui | |
parent | e99f8f0db4e427bda280587d32b5e12d114043c4 (diff) | |
download | Qt-b840d8255196241fa7c2684c0443471330f94046.zip Qt-b840d8255196241fa7c2684c0443471330f94046.tar.gz Qt-b840d8255196241fa7c2684c0443471330f94046.tar.bz2 |
simplify the semaphores initialization
there is no need in 3 separate tests since, for local semaphores, semctl(2)
always works. if it's not, well, 1 test is completely enough to check that
Merge-request: 1237
Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/embedded/qwslock.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/gui/embedded/qwslock.cpp b/src/gui/embedded/qwslock.cpp index 1d9bfb6..ae168df 100644 --- a/src/gui/embedded/qwslock.cpp +++ b/src/gui/embedded/qwslock.cpp @@ -70,8 +70,9 @@ QT_BEGIN_NAMESPACE QWSLock::QWSLock() { - semId = semget(IPC_PRIVATE, 3, IPC_CREAT | 0666); + static unsigned short initialValues[3] = { 1, 1, 0 }; + semId = semget(IPC_PRIVATE, 3, IPC_CREAT | 0666); if (semId == -1) { perror("QWSLock::QWSLock"); qFatal("Unable to create semaphore"); @@ -81,25 +82,13 @@ QWSLock::QWSLock() #endif qt_semun semval; - semval.val = 1; - - if (semctl(semId, BackingStore, SETVAL, semval) == -1) { + semval.array = initialValues; + if (semctl(semId, 0, SETALL, semval) == -1) { perror("QWSLock::QWSLock"); - qFatal("Unable to initialize backingstore semaphore"); + qFatal("Unable to initialize semaphores"); } - lockCount[BackingStore] = 0; - if (semctl(semId, Communication, SETVAL, semval) == -1) { - perror("QWSLock::QWSLock"); - qFatal("Unable to initialize communication semaphore"); - } - lockCount[Communication] = 0; - - semval.val = 0; - if (semctl(semId, RegionEvent, SETVAL, semval) == -1) { - perror("QWSLock::QWSLock"); - qFatal("Unable to initialize region event semaphore"); - } + lockCount[0] = lockCount[1] = 0; } QWSLock::QWSLock(int id) |