You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2007/03/15 15:37:07 UTC
svn commit: r518641 - /tomcat/connectors/trunk/jk/native/common/jk_shm.c
Author: mturk
Date: Thu Mar 15 07:37:07 2007
New Revision: 518641
URL: http://svn.apache.org/viewvc?view=rev&rev=518641
Log:
Add getpid() to the JkShmFile so it's always unique.
Thanks to Rainer for an idea.
Modified:
tomcat/connectors/trunk/jk/native/common/jk_shm.c
Modified: tomcat/connectors/trunk/jk/native/common/jk_shm.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_shm.c?view=diff&rev=518641&r1=518640&r2=518641
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_shm.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_shm.c Thu Mar 15 07:37:07 2007
@@ -58,7 +58,7 @@
struct jk_shm
{
size_t size;
- const char *filename;
+ char *filename;
char *lockname;
int fd;
int fd_lock;
@@ -131,7 +131,12 @@
JK_TRACE_EXIT(l);
return -1;
}
- jk_shmem.filename = "memory";
+ if (!jk_shmem.filename) {
+ if (fname)
+ jk_shmem.filename = strdup(fname);
+ else
+ jk_shmem.filename = strdup("memory");
+ }
jk_shmem.fd = 0;
jk_shmem.attached = attached;
if (!attached) {
@@ -209,6 +214,10 @@
JK_DELETE_CS(&(jk_shmem.cs), rc);
}
jk_shmem.hdr = NULL;
+ if (jk_shmem.filename) {
+ free(jk_shmem.filename);
+ jk_shmem.filename = NULL;
+ }
}
#else
@@ -328,12 +337,12 @@
JK_TRACE_EXIT(l);
return 0;
}
- jk_shmem.filename = fname;
jk_shmem.size = JK_SHM_ALIGN(sizeof(jk_shm_header_t) + sz);
- /* Use plain memory in case there is no file name */
if (!fname) {
- jk_shmem.filename = "memory";
+ /* Use plain memory in case there is no file name */
+ if (!jk_shmem.filename)
+ jk_shmem.filename = strdup("memory");
if (JK_IS_DEBUG_LEVEL(l))
jk_log(l, JK_LOG_DEBUG,
"Using process memory as shared memory");
@@ -341,10 +350,14 @@
return 0;
}
+ if (!jk_shmem.filename) {
+ jk_shmem.filename = (char *)malloc(strlen(fname) + 32);
+ sprintf(jk_shmem.filename, "%s.%d", fname, (int)getpid());
+ }
if (!attached) {
size_t size;
jk_shmem.attached = 0;
- fd = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ fd = open(jk_shmem.filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
if (fd == -1) {
jk_shmem.size = 0;
JK_TRACE_EXIT(l);
@@ -423,7 +436,7 @@
jk_shmem.hdr->h.data.workers = 0;
}
JK_INIT_CS(&(jk_shmem.cs), rc);
- if ((rc = do_shm_open_lock(fname, attached, l))) {
+ if ((rc = do_shm_open_lock(jk_shmem.filename, attached, l))) {
if (!attached) {
munmap((void *)jk_shmem.hdr, jk_shmem.size);
close(jk_shmem.fd);
@@ -482,6 +495,11 @@
if (jk_shmem.lockname) {
unlink(jk_shmem.lockname);
free(jk_shmem.lockname);
+ jk_shmem.lockname = NULL;
+ }
+ if (jk_shmem.filename) {
+ free(jk_shmem.filename);
+ jk_shmem.filename = NULL;
}
}
jk_shmem.size = 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org