Commit b8fb2b0c authored by Houkime's avatar Houkime Committed by Esteban Blanc

try to control qdb-related shared memory token files with TMPDIR

parent b83b7b1b
......@@ -50,4 +50,7 @@ eval `ipcs -q|grep ^0x|grep "[ \t]$USER[ \t]"|awk '{printf "ipcrm msg %s;", $2}'
# remove shared memory
eval `ipcs -m|grep ^0x|grep "[ \t]$USER[ \t]"|awk '{printf "ipcrm shm %s;", $2}'`
if [ $TMPDIR ]; then
rm $TMPDIR/pwr*$PWR_BUS_ID
fi
rm /tmp/pwr*$PWR_BUS_ID
......@@ -267,7 +267,7 @@ static pool_sSegment* mapSegment(
pwr_tStatus lsts;
sect_sHead* shp;
pwr_tBoolean created;
char name[16];
pwr_tFileName name;
pool_sGhead* gphp = php->gphp;
/* Map the section */
......@@ -303,7 +303,7 @@ static pool_sSegment* newSegment(pwr_tStatus* sts, pool_sHead* php,
sect_sHead* shp;
pwr_tBoolean created;
pwr_tUInt32 i;
char name[16];
pwr_tFileName name;
if (size << pool_cOffsAlign > pool_cMaxSize)
pwr_Return(NULL, sts, POOL__TOOBIG);
......@@ -352,9 +352,9 @@ static pool_sSegment* newSegment(pwr_tStatus* sts, pool_sHead* php,
The routine returns the workstr, filled in. */
static char* segName(char workstr[16], char* name, pwr_tUInt32 generation)
static char* segName(pwr_tFileName workstr, char* name, pwr_tUInt32 generation)
{
sprintf(workstr, "%.11s%4.4x", name, generation);
sprintf(workstr, "%s%4.4x", name, generation);
return workstr;
}
......
......@@ -147,7 +147,7 @@ typedef struct {
pwr_tUInt32 fragsize; /* Total size of fragments, pool_sEntry units */
pwr_tUInt32 seg; /* Segment index */
pool_eSegType type;
char name[16]; /* Name of named segment. */
pwr_tFileName name; /* Name of named segment. */
pwr_tUInt32 la_size; /* Lookaside size */
pwr_tUInt32 la_idx; /* Segment lookaside index. */
pwr_tUInt32 next_la_seg; /* Segment index */
......@@ -164,7 +164,7 @@ typedef struct {
pwr_tUInt32 generation; /* Next generation number */
pwr_tUInt32 initsize; /* Segment 0 size in pool_sEntry units */
pwr_tUInt32 extendsize; /* Segment 1..n size in pool_sEntry units */
char name[16]; /* Name (prefix) */
pwr_tFileName name; /* Name (prefix) */
pwr_tUInt32 la_idx; /* Next free lookaside index. */
pool_sList la[pool_cLists]; /* Lookaside lists. */
pool_sGsegment seg[pool_cSegs]; /* Entry for each segment */
......
......@@ -562,11 +562,23 @@ qdb_sLocal* qdb_CreateDb(pwr_tStatus* status, qdb_sInit* ip)
errh_Bugcheck(QDB__INSVIRMEM, "initiating local database");
qdb->my_pid = getpid();
/* Define paths. */
char *tmpdir = getenv("TMPDIR");
if (!tmpdir) {
tmpdir = qdb_cDefaultTmpDir;
}
sprintf(qdb->db_path, "%s/%s", tmpdir, qdb_cFileNameDatabase);
sprintf(qdb->db_lock_path, "%s/%s", tmpdir, qdb_cFileNameDbLock);
sprintf(qdb->pool_path, "%s/%s", tmpdir, qdb_cFileNamePool);
/* Create lock section. */
sp = sect_Alloc(sts, &created, &qdb->lock, sizeof(sect_sMutex),
qdb_cNameDbLock, sect_mFlags_Create);
qdb->db_lock_path, sect_mFlags_Create);
if (sp == NULL)
errh_Bugcheck(*sts, "creating db lock");
if (!created)
......@@ -577,12 +589,13 @@ qdb_sLocal* qdb_CreateDb(pwr_tStatus* status, qdb_sInit* ip)
ip = evaluateInit(ip);
pp = pool_Create(
sts, &qdb->pool, qdb_cNamePool, ip->pool_isize, ip->pool_esize);
sts, &qdb->pool, qdb->pool_path, ip->pool_isize, ip->pool_esize);
if (sp == NULL)
errh_Bugcheck(*sts, "initating pool");
qdb->g = pool_AllocNamedSegment(
sts, &qdb->pool, sizeof(*qdb->g), qdb_cNameDatabase);
sts, &qdb->pool, sizeof(*qdb->g), qdb->db_path);
if (qdb->g == NULL)
errh_Bugcheck(*sts, "database directory");
......@@ -692,7 +705,7 @@ static void unlinkPool(const char* name)
struct shmid_ds ds;
char* str = getenv(pwr_dEnvBusId);
char segname[128];
pwr_tFileName segname;
char busid[8];
strncpy(busid, (str ? str : "XXX"), 3);
......@@ -732,7 +745,7 @@ static void unlinkPool(const char* name)
void qdb_UnlinkDb()
{
char segname[128];
pwr_tFileName segname;
char busid[8];
char* str = getenv(pwr_dEnvBusId);
key_t key;
......@@ -741,14 +754,14 @@ void qdb_UnlinkDb()
/* Unlink pool. */
unlinkPool(qdb_cNamePool);
unlinkPool(qdb->pool_path);
/* Remove database lock. */
strncpy(busid, (str ? str : "XXX"), 3);
busid[3] = '\0';
sprintf(segname, "%s_%.3s", qdb_cNameDbLock, busid);
sprintf(segname, "%s_%.3s", qdb->db_lock_path, busid);
key = ftok(segname, 'P');
shm_id = shmget(key, 0, 0660);
......@@ -778,7 +791,7 @@ qdb_sLocal* qdb_MapDb(pwr_tStatus* status)
/* Map lock sections. */
sp = sect_Alloc(
sts, &created, &qdb->lock, sizeof(sect_sMutex), qdb_cNameDbLock, 0);
sts, &created, &qdb->lock, sizeof(sect_sMutex), qdb->db_lock_path, 0);
if (sp == NULL)
errh_Bugcheck(*sts, "mapping db lock");
if (created)
......@@ -792,12 +805,12 @@ qdb_sLocal* qdb_MapDb(pwr_tStatus* status)
/* Map 'pool' & 'rtdb' pools. */
pp = pool_Create(sts, &qdb->pool, qdb_cNamePool, 0, 0);
pp = pool_Create(sts, &qdb->pool, qdb->pool_path, 0, 0);
if (pp == NULL)
errh_Bugcheck(*sts, "initating pool");
qdb->g = pool_AllocNamedSegment(
sts, &qdb->pool, sizeof(*qdb->g), qdb_cNameDatabase);
sts, &qdb->pool, sizeof(*qdb->g), qdb->db_path);
if (qdb->g == NULL)
errh_Bugcheck(*sts, "database directory");
......
......@@ -70,10 +70,11 @@ static const qcom_sQid qdb_cQimport = { qdb_cIimport, 0 };
static const qcom_sQid qdb_cQexport = { qdb_cIexport, 0 };
static const qcom_sQid qdb_cQmonitor = { qdb_cImonitor, 0 };
#define qdb_cNameDatabase "/tmp/pwr_qdb"
#define qdb_cDefaultTmpDir "/tmp/"
#define qdb_cFileNameDatabase "pwr_qdb"
#define qdb_cFileNameDbLock "pwr_qdb_lock"
#define qdb_cNamePool "/tmp/pwr_qpool"
#define qdb_cNameDbLock "/tmp/pwr_qdb_lock"
#define qdb_cFileNamePool "pwr_qpool"
#if defined OS_LINUX
#define qdb_cSigMsg SIGRTMIN
......@@ -667,6 +668,10 @@ typedef struct {
qdb_sAppl* ap; /* my application */
qdb_sQue* exportque; /* the export que */
pwr_tFileName db_lock_path;
pwr_tFileName db_path;
pwr_tFileName pool_path;
} qdb_sLocal;
/* The root of all data, the only `global' variable... */
......
......@@ -37,6 +37,7 @@
/* rt_qini.c -- Queue Communication, initiation */
#include <stdlib.h>
#include <stdio.h>
#include "co_string.h"
......
......@@ -62,7 +62,7 @@ typedef union {
typedef struct {
void* base; /* Virtual address of section. */
size_t size;
char name[32]; /* Name of section. */
pwr_tFileName name; /* Name of section. */
sect_mHead flags;
} sect_sHead;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment