Skip to content

Commit

Permalink
Divided the cstat() memory pool into per processor memory pools to av…
Browse files Browse the repository at this point in the history
…oid having

two different processors return the same memory node on an apr_palloc().


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63728 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Bradley Nicholes committed Jul 24, 2002
1 parent 44e6ae8 commit 006e72e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
19 changes: 14 additions & 5 deletions file_io/netware/filestat.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ extern apr_int32_t CpuCurrentProcessor; /* system variable */
int cstat (const char *path, struct stat *buf, char **casedName, apr_pool_t *pool)
{
apr_hash_t *statCache = (apr_hash_t *)getStatCache(CpuCurrentProcessor);
apr_pool_t *gPool = (apr_pool_t *)getGlobalPool();
apr_pool_t *gPool = (apr_pool_t *)getGlobalPool(CpuCurrentProcessor);
apr_stat_entry_t *stat_entry;
struct stat *info;
apr_time_t now = apr_time_now();
Expand All @@ -233,10 +233,19 @@ int cstat (const char *path, struct stat *buf, char **casedName, apr_pool_t *poo
/* If there isn't a global pool then just stat the file
and return */
if (!gPool) {
ret = stat(path, buf);
if (ret == 0)
*casedName = case_filename(pool, path);
return ret;
char poolname[50];

if (apr_pool_create(&gPool, NULL) != APR_SUCCESS) {
ret = stat(path, buf);
if (ret == 0)
*casedName = case_filename(pool, path);
return ret;
}

sprintf (poolname, "cstat_mem_pool_%d", CpuCurrentProcessor);
apr_pool_tag(gPool, poolname);

setGlobalPool(gPool, CpuCurrentProcessor);
}

/* If we have a statCache hash table then use it.
Expand Down
4 changes: 2 additions & 2 deletions include/arch/netware/apr_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ int register_NLM(void *NLMHandle);
int unregister_NLM(void *NLMHandle);

/* Application global data management */
int setGlobalPool(void *data);
void* getGlobalPool();
int setGlobalPool(void *data, int proc);
void* getGlobalPool(int proc);
int setStatCache(void *data, int proc);
void* getStatCache(int proc);

Expand Down
21 changes: 14 additions & 7 deletions misc/netware/libprews.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

typedef struct app_data {
int initialized;
void* gPool;
void* gPool[MAX_PROCESSORS];
void* statCache[MAX_PROCESSORS];
} APP_DATA;

Expand Down Expand Up @@ -151,26 +151,34 @@ int DisposeLibraryData(void *data)
return 0;
}

int setGlobalPool(void *data)
int setGlobalPool(void *data, int proc)
{
APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);

if ((proc < 0) || (proc > (MAX_PROCESSORS-1))) {
return 0;
}

NXLock(gLibLock);

if (app_data && !app_data->gPool) {
app_data->gPool = data;
if (app_data && !app_data->gPool[proc]) {
app_data->gPool[proc] = data;
}

NXUnlock(gLibLock);
return 1;
}

void* getGlobalPool()
void* getGlobalPool(int proc)
{
APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);

if ((proc < 0) || (proc > (MAX_PROCESSORS-1))) {
return NULL;
}

if (app_data) {
return app_data->gPool;
return app_data->gPool[proc];
}

return NULL;
Expand All @@ -181,7 +189,6 @@ int setStatCache(void *data, int proc)
APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);

if ((proc < 0) || (proc > (MAX_PROCESSORS-1))) {
data = NULL;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion misc/netware/start.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ APR_DECLARE(apr_status_t) apr_initialize(void)
}

apr_signal_init(pool);
setGlobalPool((void*)pool);
// setGlobalPool((void*)pool);

return APR_SUCCESS;
}
Expand Down

0 comments on commit 006e72e

Please sign in to comment.