[mapserver-commits] r12691 - in trunk/mapserver/mapcache: include src

svn at osgeo.org svn at osgeo.org
Mon Oct 24 07:35:14 EDT 2011


Author: tbonfort
Date: 2011-10-24 04:35:13 -0700 (Mon, 24 Oct 2011)
New Revision: 12691

Modified:
   trunk/mapserver/mapcache/include/mapcache.h
   trunk/mapserver/mapcache/src/configuration.c
   trunk/mapserver/mapcache/src/configuration_xml.c
   trunk/mapserver/mapcache/src/lock.c
Log:
add configurable lock retry interval


Modified: trunk/mapserver/mapcache/include/mapcache.h
===================================================================
--- trunk/mapserver/mapcache/include/mapcache.h	2011-10-24 11:29:28 UTC (rev 12690)
+++ trunk/mapserver/mapcache/include/mapcache.h	2011-10-24 11:35:13 UTC (rev 12691)
@@ -900,8 +900,23 @@
 
     apr_table_t *metadata;
 
+    /**
+     * directory where lock files will be placed.
+     * Must be readable and writable by the apache user.
+     * Must be placed on a network mounted shared directory if multiple mapcache instances
+     * need to be synchronized
+     */
     const char *lockdir;
-    const char *endpoint; /**< the uri where the base of the service is mapped */
+    
+    /**
+     * time in nanoseconds to wait before rechecking for lockfile presence
+     */
+    apr_interval_time_t lock_retry_interval; /* time in nanoseconds to wait before rechecking for lockfile presence */
+    
+    /**
+     * the uri where the base of the service is mapped
+     */
+    const char *endpoint;
 
     /* for fastcgi only */
     int autoreload; /* should the modification time of the config file be recorded

Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c	2011-10-24 11:29:28 UTC (rev 12690)
+++ trunk/mapserver/mapcache/src/configuration.c	2011-10-24 11:35:13 UTC (rev 12691)
@@ -48,6 +48,8 @@
             ,config->lockdir,apr_strerror(rv,errmsg,120));
       return;
    }
+
+   /* only remove lockfiles if we're not in cgi mode */
    if(!cgi) {
       apr_finfo_t finfo;
       while ((apr_dir_read(&finfo, APR_FINFO_DIRENT|APR_FINFO_TYPE|APR_FINFO_NAME, lockdir)) == APR_SUCCESS) {
@@ -231,6 +233,9 @@
    }
    mapcache_configuration_add_grid(cfg,grid,"g");
 
+   /* default retry interval is 1/100th of a second, i.e. 10000 microseconds */
+   cfg->lock_retry_interval = 10000;
+
    cfg->loglevel = MAPCACHE_WARN;
    cfg->autoreload = 0;
 

Modified: trunk/mapserver/mapcache/src/configuration_xml.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration_xml.c	2011-10-24 11:29:28 UTC (rev 12690)
+++ trunk/mapserver/mapcache/src/configuration_xml.c	2011-10-24 11:35:13 UTC (rev 12691)
@@ -925,6 +925,16 @@
    } else {
       config->lockdir = apr_pstrdup(ctx->pool,"/tmp");
    }
+
+   if((node = ezxml_child(doc,"lock_retry")) != NULL) {
+      char *endptr;
+      config->lock_retry_interval = (unsigned int)strtol(node->txt,&endptr,10);
+      if(*endptr != 0 || config->lock_retry_interval < 0) {
+         ctx->set_error(ctx, 400, "failed to parse lock_retry microseconds \"%s\". Expecting a positive integer",
+               node->txt);
+         return;
+      }
+   }
    
    if((node = ezxml_child(doc,"log_level")) != NULL) {
       if(!strcasecmp(node->txt,"debug")) {

Modified: trunk/mapserver/mapcache/src/lock.c
===================================================================
--- trunk/mapserver/mapcache/src/lock.c	2011-10-24 11:29:28 UTC (rev 12690)
+++ trunk/mapserver/mapcache/src/lock.c	2011-10-24 11:35:13 UTC (rev 12691)
@@ -62,8 +62,8 @@
       }
 #endif
       while(!APR_STATUS_IS_ENOENT(rv)) {
-         /* sleep for a tenth of a second */
-         apr_sleep(1000);
+         /* 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);



More information about the mapserver-commits mailing list