[mapserver-commits] r12893 - trunk/mapserver/mapcache/src
svn at osgeo.org
svn at osgeo.org
Tue Dec 13 12:03:10 EST 2011
Author: tbonfort
Date: 2011-12-13 09:03:10 -0800 (Tue, 13 Dec 2011)
New Revision: 12893
Modified:
trunk/mapserver/mapcache/src/lock.c
Log:
avoid opening the lockfile repeatedly to check for existence, use stat
Modified: trunk/mapserver/mapcache/src/lock.c
===================================================================
--- trunk/mapserver/mapcache/src/lock.c 2011-12-13 17:01:11 UTC (rev 12892)
+++ trunk/mapserver/mapcache/src/lock.c 2011-12-13 17:03:10 UTC (rev 12893)
@@ -50,12 +50,13 @@
apr_file_t *lockfile;
apr_status_t rv;
/* create the lockfile */
- rv = apr_file_open(&lockfile,lockname,APR_WRITE|APR_CREATE|APR_EXCL,APR_OS_DEFAULT,ctx->pool);
+ rv = apr_file_open(&lockfile,lockname,APR_WRITE|APR_CREATE|APR_EXCL|APR_XTHREAD,APR_OS_DEFAULT,ctx->pool);
/* if the file already exists, wait for it to disappear */
/* TODO: check the lock isn't stale (i.e. too old) */
if( rv != APR_SUCCESS ) {
- rv = apr_file_open(&lockfile,lockname,APR_READ,APR_OS_DEFAULT,ctx->pool);
+ apr_finfo_t info;
+ rv = apr_stat(&info,lockname,0,ctx->pool);
#ifdef DEBUG
if(!APR_STATUS_IS_ENOENT(rv)) {
ctx->log(ctx, MAPCACHE_DEBUG, "waiting on resource lock %s", resource);
@@ -64,10 +65,7 @@
while(!APR_STATUS_IS_ENOENT(rv)) {
/* sleep for the configured number of micro-seconds (default is 1/100th of a second) */
apr_sleep(ctx->config->lock_retry_interval);
- rv = apr_file_open(&lockfile,lockname,APR_READ,APR_OS_DEFAULT,ctx->pool);
- if(rv == APR_SUCCESS) {
- apr_file_close(lockfile);
- }
+ rv = apr_stat(&info,lockname,0,ctx->pool);
}
return MAPCACHE_FALSE;
} else {
More information about the mapserver-commits
mailing list