[mapserver-commits] r12230 - in trunk/mapserver/mapcache: . include
src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:09:08 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:09:08 -0700 (Fri, 26 Aug 2011)
New Revision: 12230
Modified:
trunk/mapserver/mapcache/configure
trunk/mapserver/mapcache/configure.in
trunk/mapserver/mapcache/geocache.xml
trunk/mapserver/mapcache/include/geocache.h
trunk/mapserver/mapcache/src/configuration.c
trunk/mapserver/mapcache/src/lock.c
Log:
add apache-restart task
thomas.bonfort | 2011-01-10 14:58:04 +0100 (Mon, 10 Jan 2011)
Modified: trunk/mapserver/mapcache/configure
===================================================================
--- trunk/mapserver/mapcache/configure 2011-08-26 11:09:01 UTC (rev 12229)
+++ trunk/mapserver/mapcache/configure 2011-08-26 11:09:08 UTC (rev 12230)
@@ -1531,52 +1531,6 @@
} # ac_fn_c_try_run
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- rm -f conftest.$ac_objext conftest$ac_exeext
- if { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- grep -v '^ *+' conftest.err >conftest.er1
- cat conftest.er1 >&5
- mv -f conftest.er1 conftest.err
- fi
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext && {
- test "$cross_compiling" = yes ||
- $as_test_x conftest$ac_exeext
- }; then :
- ac_retval=0
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=1
-fi
- # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
- # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
- # interfere with the next link command; also delete a directory that is
- # left behind by Apple's compiler. We do this before executing the actions.
- rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
-
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
@@ -1694,6 +1648,52 @@
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@@ -3268,6 +3268,42 @@
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+ac_fn_c_check_header_mongrel "$LINENO" "semaphore.h" "ac_cv_header_semaphore_h" "$ac_includes_default"
+if test "x$ac_cv_header_semaphore_h" = xyes; then :
+
+else
+ as_fn_error $? "cannot find semaphore.h" "$LINENO" 5
+fi
+
+
+ac_fn_c_check_header_mongrel "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h" "$ac_includes_default"
+if test "x$ac_cv_header_fcntl_h" = xyes; then :
+
+else
+ as_fn_error $? "cannot find fcntl.h" "$LINENO" 5
+fi
+
+
+
+
# Check whether --enable-module was given.
if test "${enable_module+set}" = set; then :
enableval=$enable_module;
@@ -3511,25 +3547,8 @@
fi
fi
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-fi
-done
-
-
-
-
# Check whether --with-fastcgi was given.
if test "${with_fastcgi+set}" = set; then :
withval=$with_fastcgi;
@@ -3781,7 +3800,7 @@
APR_INC=`$APRCONFIG --includes`
- APR_LIBS=`$APRCONFIG --link-ld`
+ APR_LIBS=`$APRCONFIG --link-libtool`
LIBTOOL=`$APRCONFIG --apr-libtool`
Modified: trunk/mapserver/mapcache/configure.in
===================================================================
--- trunk/mapserver/mapcache/configure.in 2011-08-26 11:09:01 UTC (rev 12229)
+++ trunk/mapserver/mapcache/configure.in 2011-08-26 11:09:08 UTC (rev 12230)
@@ -184,7 +184,7 @@
fi
AC_SUBST(APRCONFIG)
AC_SUBST(APR_INC,`$APRCONFIG --includes`)
- AC_SUBST(APR_LIBS,`$APRCONFIG --link-ld`)
+ AC_SUBST(APR_LIBS,`$APRCONFIG --link-libtool`)
AC_SUBST(LIBTOOL, `$APRCONFIG --apr-libtool`)
])
@@ -399,6 +399,11 @@
DEBUG_CHECK
+
+AC_CHECK_HEADER([semaphore.h],,[AC_MSG_ERROR([cannot find semaphore.h])])
+AC_CHECK_HEADER([fcntl.h],,[AC_MSG_ERROR([cannot find fcntl.h])])
+
+
AC_ARG_ENABLE(module,
AC_HELP_STRING([--enable-module],[Enable apache module building]),
,
Modified: trunk/mapserver/mapcache/geocache.xml
===================================================================
--- trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:09:01 UTC (rev 12229)
+++ trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:09:08 UTC (rev 12230)
@@ -386,13 +386,6 @@
-->
<merge_format>PNGQ_FAST</merge_format>
- <!-- this is the location where locks will be stored when a tile
- is not in the cache.
- this directory MUST exist, and be accessible for reading and
- writing by the user running apache (usually www-data or nobody)
- -->
- <lock_dir>/tmp</lock_dir>
-
<!-- services
services that will be responded to by mod-geocache
each service is accessible at the url http://host/path/to/geocache/{service},
Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:09:01 UTC (rev 12229)
+++ trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:09:08 UTC (rev 12230)
@@ -599,11 +599,6 @@
geocache_image_format *merge_format;
/**
- * directory where we store file locks
- */
- char *lockdir;
-
- /**
* how should error messages be reported to the user
*/
geocache_error_reporting reporting;
Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c 2011-08-26 11:09:01 UTC (rev 12229)
+++ trunk/mapserver/mapcache/src/configuration.c 2011-08-26 11:09:08 UTC (rev 12230)
@@ -94,7 +94,6 @@
geocache_imageio_create_jpeg_format(pool,"JPEG",95),
"JPEG");
cfg->merge_format = geocache_configuration_get_image_format(cfg,"PNG");
- cfg->lockdir = NULL;
cfg->reporting = GEOCACHE_REPORT_MSG;
grid = geocache_grid_create(pool);
@@ -828,9 +827,7 @@
}
config->merge_format = format;
} else if(!xmlStrcmp(cur_node->name, BAD_CAST "lock_dir")) {
- xmlChar *value = xmlNodeGetContent(cur_node);
- config->lockdir = apr_pstrdup(ctx->pool, (char*)value);
- xmlFree(value);
+ //do nothing, not used anymore
} else {
ctx->set_error(ctx, GEOCACHE_PARSE_ERROR, "failed to parse geocache config file %s: unknown tag <%s>",
filename, cur_node->name);
@@ -855,32 +852,6 @@
return;
}
- /* check our lock directory exists */
- if(!config->lockdir) {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "no lock directory configured."
- " You should add one with the <lock_dir> configuration tag");
- return;
- } else {
- apr_dir_t *dir;
- int ret = apr_dir_open(&dir,config->lockdir, ctx->pool);
- if(APR_SUCCESS != ret) {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "failed to open directory %s, does it exist?",config->lockdir);
- return;
- }
- apr_dir_close(dir);
-#ifdef notused
- testlockfilename = apr_psprintf(ctx->pool,"%s/test.lock",config->lockdir);
- if(apr_file_open(&testlockfile, testlockfilename, APR_FOPEN_CREATE|APR_FOPEN_WRITE,
- APR_OS_DEFAULT, ctx->pool) != APR_SUCCESS) {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "failed to create test lockfile %s",testlockfilename);
- return; /* we could not create the file */
- }
- apr_file_close(testlockfile);
- apr_file_remove(testlockfilename,ctx->pool);
-#endif
- }
-
-
if(!config->services[GEOCACHE_SERVICE_WMS] &&
!config->services[GEOCACHE_SERVICE_TMS]) {
ctx->set_error(ctx, GEOCACHE_PARSE_ERROR, "no services configured."
Modified: trunk/mapserver/mapcache/src/lock.c
===================================================================
--- trunk/mapserver/mapcache/src/lock.c 2011-08-26 11:09:01 UTC (rev 12229)
+++ trunk/mapserver/mapcache/src/lock.c 2011-08-26 11:09:08 UTC (rev 12230)
@@ -17,11 +17,13 @@
#include "geocache.h"
#include <apr_file_io.h>
#include <apr_strings.h>
+#include <semaphore.h>
+#include <errno.h>
+#include <fcntl.h>
char *geocache_tileset_tile_lock_key(geocache_context *ctx, geocache_tile *tile) {
return apr_psprintf(ctx->pool,
- "%s/%s-%d-%d-%d.lck",
- tile->tileset->config->lockdir,
+ "%s-%d-%d-%d",
tile->tileset->name,
tile->z, tile->y, tile->x);
}
@@ -34,37 +36,14 @@
* \private \memberof geocache_cache_disk
*/
void geocache_tileset_tile_lock(geocache_context *ctx, geocache_tile *tile) {
- char *lockname;
- apr_file_t *f;
- apr_status_t rv;
- lockname = geocache_tileset_tile_lock_key(ctx,tile);
- /*create file, and fail if it already exists*/
- if (apr_file_open(&f, lockname,
- APR_FOPEN_CREATE | APR_FOPEN_EXCL | APR_FOPEN_WRITE | APR_FOPEN_SHARELOCK | APR_FOPEN_BUFFERED | APR_FOPEN_BINARY,
- APR_OS_DEFAULT, ctx->pool) != APR_SUCCESS) {
- /*
- * opening failed, is this because we don't have write permissions, or because
- * the file already exists?
- */
- if (apr_file_open(&f, lockname, APR_FOPEN_CREATE | APR_FOPEN_WRITE, APR_OS_DEFAULT, ctx->pool) != APR_SUCCESS) {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "failed to create lockfile %s", lockname);
- return; /* we could not create the file */
- } else {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "failed to create lockfile %s, because it already exists", lockname);
- apr_file_close(f);
- return; /* we have write access, but the file already exists */
- }
- }
- rv = apr_file_lock(f, APR_FLOCK_EXCLUSIVE | APR_FLOCK_NONBLOCK);
- if (rv != APR_SUCCESS) {
- if (rv == EAGAIN) {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "####### TILE LOCK ######## file %s is already locked", lockname);
- } else {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "failed to lock file %s", lockname);
- }
- return;
- }
- tile->lock = f;
+ char *lockname = geocache_tileset_tile_lock_key(ctx,tile);
+ sem_t *lock;
+ if ((lock = sem_open(lockname, O_CREAT|O_EXCL, 0644, 1)) == SEM_FAILED) {
+ ctx->set_error(ctx,GEOCACHE_MUTEX_ERROR, "failed to create pthread semaphore %s",lockname);
+ return;
+ }
+ sem_wait(lock);
+ tile->lock = lock;
}
/**
@@ -74,35 +53,20 @@
* \sa geocache_cache::tile_lock_exists()
*/
void geocache_tileset_tile_unlock(geocache_context *ctx, geocache_tile *tile) {
- apr_file_t *f = (apr_file_t*) tile->lock;
- const char *lockname;
+ sem_t *lock = (sem_t*) tile->lock;
+ int semvalue;
+ const char *lockname = geocache_tileset_tile_lock_key(ctx,tile);
if (!tile->lock) {
- lockname = geocache_tileset_tile_lock_key(ctx, tile);
- ctx->log(ctx, GEOCACHE_ERROR, "###### TILE UNLOCK ######### attempting to unlock tile %s not created by this thread", lockname);
-
- /*fail if the lock does not exists*/
- if (apr_file_open(&f, lockname, APR_FOPEN_READ, APR_OS_DEFAULT, ctx->pool) != APR_SUCCESS) {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "###### TILE UNLOCK ######### tile %s is not locked", lockname);
- return;
- }
+ ctx->set_error(ctx,GEOCACHE_MUTEX_ERROR,"###### TILE UNLOCK ######### attempting to unlock tile %s not created by this thread", lockname);
+ return;
+ }
+ sem_post(lock);
+ sem_getvalue(lock,&semvalue);
+ if(semvalue>0) {
+ sem_unlink(lockname);
} else {
- f = (apr_file_t*) tile->lock;
- apr_file_name_get(&lockname, f);
+ sem_close(lock);
}
-
-
- apr_file_remove(lockname, ctx->pool);
-
- int rv = apr_file_unlock(f);
- if (rv != APR_SUCCESS) {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "failed to unlock file %s", lockname);
- return;
- }
- rv = apr_file_close(f);
- if (rv != APR_SUCCESS) {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "failed to close file %s", lockname);
- return;
- }
tile->lock = NULL;
}
@@ -113,16 +77,21 @@
*/
int geocache_tileset_tile_lock_exists(geocache_context *ctx, geocache_tile *tile) {
char *lockname;
- apr_file_t *f;
if (tile->lock)
return GEOCACHE_TRUE;
lockname = geocache_tileset_tile_lock_key(ctx, tile);
- if (apr_file_open(&f, lockname, APR_FOPEN_READ, APR_OS_DEFAULT, ctx->pool) != APR_SUCCESS) {
- return GEOCACHE_FALSE;
- } else {
- apr_file_close(f);
- return GEOCACHE_TRUE;
- }
+ sem_t *lock = sem_open(lockname, 0, 0644, 1) ;
+ if (lock == SEM_FAILED) {
+ if(errno == ENOENT) {
+ return GEOCACHE_FALSE;
+ } else {
+ ctx->set_error(ctx,GEOCACHE_MUTEX_ERROR,"lock_exists: failed to open mutex %s",lockname);
+ return GEOCACHE_FALSE;
+ }
+ } else {
+ sem_close(lock);
+ return GEOCACHE_TRUE;
+ }
}
/**
@@ -133,7 +102,7 @@
*/
void geocache_tileset_tile_lock_wait(geocache_context *ctx, geocache_tile *tile) {
char *lockname;
- apr_file_t *f;
+ sem_t *lock;
#ifdef DEBUG
if (tile->lock) {
ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "### BUG ### waiting for a lock we have created ourself");
@@ -141,11 +110,25 @@
}
#endif
lockname = geocache_tileset_tile_lock_key(ctx, tile);
- if (apr_file_open(&f, lockname, APR_FOPEN_READ, APR_OS_DEFAULT, ctx->pool) != APR_SUCCESS) {
- ctx->set_error(ctx, GEOCACHE_DISK_ERROR, "### BUG ### waiting for a lock on an unlocked file");
- return;
+ lock = sem_open(lockname, 0, 0644, 1) ;
+ if( lock == SEM_FAILED ) {
+ if(errno == ENOENT) {
+ /* the lock doesn't exist (anymore?) */
+ return;
+ } else {
+ ctx->set_error(ctx,GEOCACHE_MUTEX_ERROR, "lock_wait: failed to open semaphore %s",lockname);
+ return;
+ }
+ } else {
+ int semvalue;
+ sem_wait(lock);
+ sem_post(lock);
+ sem_getvalue(lock,&semvalue);
+ if(semvalue>0) {
+ sem_unlink(lockname);
+ } else {
+ sem_close(lock);
+ }
}
- apr_file_lock(f, APR_FLOCK_SHARED);
- apr_file_close(f);
}
More information about the mapserver-commits
mailing list