From 3d9c3cde5d5086bb738cadb652644e04610df3ad Mon Sep 17 00:00:00 2001 From: rrelyea Date: Wed, 15 Aug 2007 00:34:17 +0000 Subject: Use a less obscure name for the cache file. Don't try to initialize the file if we couldn't open it. git-svn-id: http://svn.fedorahosted.org/svn/coolkey/trunk@68 fba4d07e-fe0f-4d7f-8147-e0026e666dc0 --- src/coolkey/machdep.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/coolkey/machdep.cpp b/src/coolkey/machdep.cpp index d7ce38e..21c73cf 100644 --- a/src/coolkey/machdep.cpp +++ b/src/coolkey/machdep.cpp @@ -195,10 +195,10 @@ void OSSleep(int time) #ifdef FULL_CLEANUP #define RESERVED_OFFSET 256 -#define MEMSEGPATH BASEPATH"/pk11ipc" +#define MEMSEGPATH BASEPATH"/coolkey-lock" #else #define RESERVED_OFFSET 0 -#define MEMSEGPATH BASEPATH"/pk11ipc1" +#define MEMSEGPATH BASEPATH"/coolkey" #endif struct SHMemData { @@ -273,10 +273,7 @@ SHMem::initSegment(const char *name, int size, bool &init) shmemData->fd = open(shmemData->path, O_CREAT|O_RDWR|O_EXCL|O_APPEND|O_EXLOCK, mode); - if ((shmemData->fd < 0) && errno == EEXIST) { - needInit = false; - shmemData->fd = open(shmemData->path,O_RDWR|O_EXLOCK|O_NOFOLLOW, mode); - } else { + if (shmemData->fd >= 0) { char *buf; int len = size+RESERVED_OFFSET; @@ -291,6 +288,9 @@ SHMem::initSegment(const char *name, int size, bool &init) } write(shmemData->fd,buf,len); free(buf); + } else if (errno == EEXIST) { + needInit = false; + shmemData->fd = open(shmemData->path,O_RDWR|O_EXLOCK|O_NOFOLLOW, mode); } if (shmemData->fd < 0) { delete shmemData; -- cgit v1.2.3