Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 60778 invoked by uid 500); 14 Jan 2003 00:51:37 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 60767 invoked from network); 14 Jan 2003 00:51:37 -0000 Date: 14 Jan 2003 00:51:36 -0000 Message-ID: <20030114005136.75241.qmail@icarus.apache.org> From: bnicholes@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/include apr.hnw X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bnicholes 2003/01/13 16:51:36 Modified: file_io/unix open.c misc/netware libprews.c file_io/netware filestat.c include/arch/netware apr_private.h include apr.hnw Log: Remove the stat info caching for NetWare Revision Changes Path 1.109 +0 -25 apr/file_io/unix/open.c Index: open.c =================================================================== RCS file: /home/cvs/apr/file_io/unix/open.c,v retrieving revision 1.108 retrieving revision 1.109 diff -u -r1.108 -r1.109 --- open.c 7 Jan 2003 00:52:53 -0000 1.108 +++ open.c 14 Jan 2003 00:51:35 -0000 1.109 @@ -105,13 +105,6 @@ apr_status_t rv; #endif -#ifdef NETWARE - apr_hash_t *statCache = NULL; - apr_stat_entry_t *stat_entry = NULL; - NXPathCtx_t pathCtx = 0; - int identity; -#endif - if ((flag & APR_READ) && (flag & APR_WRITE)) { oflags = O_RDWR; } @@ -157,30 +150,12 @@ } #endif -#ifdef NETWARE - if (!getcwdpath(NULL, &pathCtx, CTX_ACTUAL_CWD) && - !get_identity (pathCtx, &identity) && !identity) { - - statCache = (apr_hash_t *)getStatCache(CpuCurrentProcessor); - if (statCache) { - stat_entry = (apr_stat_entry_t*) apr_hash_get(statCache, fname, APR_HASH_KEY_STRING); - } - } - - if (stat_entry) { - errno = NXFileOpen (stat_entry->pathCtx, stat_entry->casedName, oflags, &fd); - } - else { -#endif if (perm == APR_OS_DEFAULT) { fd = open(fname, oflags, 0666); } else { fd = open(fname, oflags, apr_unix_perms2mode(perm)); } -#ifdef NETWARE - } -#endif if (fd < 0) { return errno; } 1.9 +0 -65 apr/misc/netware/libprews.c Index: libprews.c =================================================================== RCS file: /home/cvs/apr/misc/netware/libprews.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- libprews.c 2 Dec 2002 21:16:45 -0000 1.8 +++ libprews.c 14 Jan 2003 00:51:35 -0000 1.9 @@ -144,71 +144,6 @@ return 0; } -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[proc]) { - app_data->gPool[proc] = data; - } - - NXUnlock(gLibLock); - return 1; -} - -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[proc]; - } - - return NULL; -} - -int setStatCache(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->statCache[proc]) { - app_data->statCache[proc] = data; - } - - NXUnlock(gLibLock); - return 1; -} - -void* getStatCache(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->statCache[proc]; - } - - return NULL; -} 1.25 +4 -180 apr/file_io/netware/filestat.c Index: filestat.c =================================================================== RCS file: /home/cvs/apr/file_io/netware/filestat.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- filestat.c 7 Jan 2003 00:52:51 -0000 1.24 +++ filestat.c 14 Jan 2003 00:51:36 -0000 1.25 @@ -184,191 +184,17 @@ return apr_file_perms_set(fname, finfo.protection); } -int cstat (NXPathCtx_t pathCtx, 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(CpuCurrentProcessor); - apr_stat_entry_t *stat_entry; - struct stat *info; - apr_time_t now = apr_time_now(); - char *key; - int ret; - int found = 0; - - *casedName = NULL; - errno = 0; - - /* If there isn't a global pool then just stat the file - and return */ - if (!gPool) { - char poolname[50]; - - if (apr_pool_create(&gPool, NULL) != APR_SUCCESS) { - ret = getstat(pathCtx, path, buf, ST_STAT_BITS|ST_NAME_BIT); - if (ret == 0) { - *casedName = apr_pstrdup (pool, buf->st_name); - return 0; - } - else { - errno = ret; - return -1; - } - } - - sprintf (poolname, "cstat_mem_pool_%d", CpuCurrentProcessor); - apr_pool_tag(gPool, apr_pstrdup(gPool, poolname)); - - setGlobalPool(gPool, CpuCurrentProcessor); - } - - /* If we have a statCache hash table then use it. - Otherwise we need to create it and initialized it - with a new mutex lock. */ - if (!statCache) { - statCache = apr_hash_make(gPool); - setStatCache((void*)statCache, CpuCurrentProcessor); - } - - /* If we have a statCache then try to pull the information - from the cache. Otherwise just stat the file and return.*/ - if (statCache) { - stat_entry = (apr_stat_entry_t*) apr_hash_get(statCache, path, APR_HASH_KEY_STRING); - /* If we got an entry then check the expiration time. If the entry - hasn't expired yet then copy the information and return. */ - if (stat_entry) { - if ((now - stat_entry->expire) <= APR_USEC_PER_SEC) { - memcpy (buf, &(stat_entry->info), sizeof(struct stat)); - *casedName = apr_pstrdup (pool, stat_entry->casedName); - found = 1; - } - } - - /* Since we are creating a separate stat cache for each processor, we - don't need to worry about locking the hash table before manipulating - it. */ - if (!found) { - /* Bind the thread to the current cpu so that we don't wake - up on some other cpu and try to manipulate the wrong cache. */ - NXThreadBind (CpuCurrentProcessor); - - /* If we don't have a stat_entry then create one, copy - the data and add it to the hash table. */ - if (!stat_entry) { - char *dirPath = NULL, *fname = NULL; - char *ptr; - int err, len; - - ret = getstat(pathCtx, path, buf, ST_STAT_BITS|ST_NAME_BIT); - - if (ret) { - NXThreadBind (NX_THR_UNBOUND); - errno = ret; - return -1; - } - - if (filetype_from_mode(buf->st_mode) == APR_DIR) { - dirPath = apr_pstrdup (pool, path); - len = strlen (dirPath) - strlen(buf->st_name); - dirPath[len-1] = '\0'; - } - else if (filetype_from_mode(buf->st_mode) == APR_REG) { - dirPath = apr_pstrdup (pool, path); - ptr = strrchr (dirPath, '/'); - if (ptr) { - *ptr = '\0'; - } - } - - err = NXCreatePathContext(pathCtx, dirPath, 0, NULL, &pathCtx); - - key = apr_pstrdup (gPool, path); - stat_entry = apr_palloc (gPool, sizeof(apr_stat_entry_t)); - memcpy (&(stat_entry->info), buf, sizeof(struct stat)); - stat_entry->casedName = (stat_entry->info).st_name; - *casedName = apr_pstrdup(pool, stat_entry->casedName); - stat_entry->expire = now; - if (err == 0) { - stat_entry->pathCtx = pathCtx; - } - else { - stat_entry->pathCtx = 0; - } - apr_hash_set(statCache, key, APR_HASH_KEY_STRING, stat_entry); - } - else { - NXDirAttrNks_t dirInfo; - - /* If we have a path context then get the info the fast way. Otherwise - just default to getting the stat info from stat() */ - if (stat_entry->pathCtx) { - ret = getstat(stat_entry->pathCtx, stat_entry->casedName, buf, - ST_MODE_BIT|ST_ATIME_BIT|ST_MTIME_BIT|ST_CTIME_BIT|ST_SIZE_BIT|ST_NAME_BIT); - } - else { - ret = getstat(pathCtx, path, buf, - ST_MODE_BIT|ST_ATIME_BIT|ST_MTIME_BIT|ST_CTIME_BIT|ST_SIZE_BIT|ST_NAME_BIT); - } - - if (ret) { - NXThreadBind (NX_THR_UNBOUND); - errno = ret; - return -1; - } - else { - (stat_entry->info).st_atime.tv_sec = (buf->st_atime).tv_sec; - (stat_entry->info).st_mtime.tv_sec = (buf->st_mtime).tv_sec; - (stat_entry->info).st_ctime.tv_sec = (buf->st_ctime).tv_sec; - (stat_entry->info).st_size = buf->st_size; - (stat_entry->info).st_mode = buf->st_mode; - memcpy ((stat_entry->info).st_name, buf->st_name, sizeof(buf->st_name)); - memcpy (buf, &(stat_entry->info), sizeof(struct stat)); - } - - /* If we do have a stat_entry then it must have expired. Just - copy the data and reset the expiration. */ - *casedName = apr_pstrdup(pool, stat_entry->casedName); - stat_entry->expire = now; - } - NXThreadBind (NX_THR_UNBOUND); - } - } - else { - ret = getstat(pathCtx, path, buf, ST_STAT_BITS|ST_NAME_BIT); - if (ret == 0) { - *casedName = apr_pstrdup(pool, buf->st_name); - } - else { - errno = ret; - return -1; - } - } - return 0; -} - APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, apr_int32_t wanted, apr_pool_t *pool) { struct stat info; int srv; - char *casedName = NULL; NXPathCtx_t pathCtx = 0; - int identity; - int ret; getcwdpath(NULL, &pathCtx, CTX_ACTUAL_CWD); - ret= get_identity (pathCtx, &identity); - - if (ret || identity) { - srv = getstat(pathCtx, fname, &info, ST_STAT_BITS|ST_NAME_BIT); - if (srv == 0) { - casedName = apr_pstrdup(pool, info.st_name); - } - errno = srv; - } - else { - srv = cstat(pathCtx, fname, &info, &casedName, pool); - } + srv = getstat(pathCtx, fname, &info, ST_STAT_BITS|ST_NAME_BIT); + errno = srv; if (srv == 0) { finfo->pool = pool; @@ -377,10 +203,8 @@ if (wanted & APR_FINFO_LINK) wanted &= ~APR_FINFO_LINK; if (wanted & APR_FINFO_NAME) { - if (casedName) { - finfo->name = casedName; - finfo->valid |= APR_FINFO_NAME; - } + finfo->name = apr_pstrdup(pool, info.st_name); + finfo->valid |= APR_FINFO_NAME; } return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS; } 1.17 +0 -6 apr/include/arch/netware/apr_private.h Index: apr_private.h =================================================================== RCS file: /home/cvs/apr/include/arch/netware/apr_private.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- apr_private.h 1 Jan 2003 00:01:48 -0000 1.16 +++ apr_private.h 14 Jan 2003 00:51:36 -0000 1.17 @@ -165,12 +165,6 @@ int register_NLM(void *NLMHandle); int unregister_NLM(void *NLMHandle); -/* Application global data management */ -int setGlobalPool(void *data, int proc); -void* getGlobalPool(int proc); -int setStatCache(void *data, int proc); -void* getStatCache(int proc); - /* Redefine malloc to use the library malloc call so that all of the memory resources will be owned and can be shared by the library. */ 1.27 +0 -2 apr/include/apr.hnw Index: apr.hnw =================================================================== RCS file: /home/cvs/apr/include/apr.hnw,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- apr.hnw 13 Jan 2003 17:57:47 -0000 1.26 +++ apr.hnw 14 Jan 2003 00:51:36 -0000 1.27 @@ -362,8 +362,6 @@ typedef struct app_data { int initialized; - void* gPool[MAX_PROCESSORS]; - void* statCache[MAX_PROCESSORS]; void* gs_aHooksToSort; void* gs_phOptionalHooks; void* gs_phOptionalFunctions;