summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qsharedmemory_unix.cpp
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2011-01-21 15:29:01 +0000
committerShane Kearns <shane.kearns@accenture.com>2011-01-21 15:30:25 +0000
commitacd04e69bd404657638d3a95eea3a5946008cf03 (patch)
tree213c74380b570cc15fc365544fdd742c9b3ce0af /src/corelib/kernel/qsharedmemory_unix.cpp
parentc17e49e8a481f96a4b953d8fcf41678fc1b2f9bc (diff)
get rid of extra calls to handle()
in create(), handle() is called a few lines early; in attach(), QSharedMemory::attach() calls handle() as a preparation step; in detach(), well, if we're here, unix_key is valid anyways... Merge-request: 1018 Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'src/corelib/kernel/qsharedmemory_unix.cpp')
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index 3cd17f18c9..ddb0e341d6 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -199,7 +199,7 @@ bool QSharedMemoryPrivate::create(int size)
}
// create
- if (-1 == shmget(handle(), size, 0666 | IPC_CREAT | IPC_EXCL)) {
+ if (-1 == shmget(unix_key, size, 0666 | IPC_CREAT | IPC_EXCL)) {
QString function = QLatin1String("QSharedMemory::create");
switch (errno) {
case EINVAL:
@@ -220,10 +220,7 @@ bool QSharedMemoryPrivate::create(int size)
bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
{
// grab the shared memory segment id
- if (!handle())
- return false;
-
- int id = shmget(handle(), 0, (mode == QSharedMemory::ReadOnly ? 0444 : 0660));
+ int id = shmget(unix_key, 0, (mode == QSharedMemory::ReadOnly ? 0444 : 0660));
if (-1 == id) {
setErrorString(QLatin1String("QSharedMemory::attach (shmget)"));
return false;
@@ -268,10 +265,8 @@ bool QSharedMemoryPrivate::detach()
size = 0;
// Get the number of current attachments
- if (!handle())
- return false;
- int id = shmget(handle(), 0, 0444);
- unix_key = 0;
+ int id = shmget(unix_key, 0, 0444);
+ cleanHandle();
struct shmid_ds shmid_ds;
if (0 != shmctl(id, IPC_STAT, &shmid_ds)) {