[mapserver-commits] r12637 - trunk/mapserver/mapcache/src
svn at osgeo.org
svn at osgeo.org
Fri Oct 7 06:46:38 EDT 2011
Author: tbonfort
Date: 2011-10-07 03:46:38 -0700 (Fri, 07 Oct 2011)
New Revision: 12637
Modified:
trunk/mapserver/mapcache/src/mapcache_seed.c
Log:
implement global mutex for the seeder (shouldn't be needed, but let's play safe)
Modified: trunk/mapserver/mapcache/src/mapcache_seed.c
===================================================================
--- trunk/mapserver/mapcache/src/mapcache_seed.c 2011-10-07 04:01:46 UTC (rev 12636)
+++ trunk/mapserver/mapcache/src/mapcache_seed.c 2011-10-07 10:46:38 UTC (rev 12637)
@@ -67,6 +67,8 @@
int seededtilestot=0, seededtiles=0, queuedtilestot=0;
struct timeval lastlogtime,starttime;
+apr_thread_mutex_t *global_lock;
+
typedef enum {
MAPCACHE_CMD_SEED,
MAPCACHE_CMD_STOP,
@@ -118,9 +120,20 @@
}
}
-void dummy_lock_aquire(mapcache_context *ctx){}
-void dummy_lock_release(mapcache_context *ctx){}
-void dummy_log(mapcache_context *ctx, mapcache_log_level level, char *msg, ...){
+void seed_lock_aquire(mapcache_context *ctx){
+ int rv = apr_thread_mutex_lock(global_lock);
+ if(rv != APR_SUCCESS) {
+ ctx->set_error(ctx,500,"failed to aquire seed mutex");
+ }
+}
+void seed_lock_release(mapcache_context *ctx){
+ int rv = apr_thread_mutex_unlock(global_lock);
+ if(rv != APR_SUCCESS) {
+ ctx->set_error(ctx,500,"failed to release seed mutex");
+ }
+}
+
+void seed_log(mapcache_context *ctx, mapcache_log_level level, char *msg, ...){
if(verbose) {
va_list args;
va_start(args,msg);
@@ -379,7 +392,7 @@
static void* APR_THREAD_FUNC seed_thread(apr_thread_t *thread, void *data) {
mapcache_context seed_ctx = ctx;
- seed_ctx.log = dummy_log;
+ seed_ctx.log = seed_log;
apr_pool_create(&seed_ctx.pool,ctx.pool);
mapcache_tile *tile = mapcache_tileset_tile_create(ctx.pool, tileset, grid_link);
tile->dimensions = dimensions;
@@ -481,10 +494,13 @@
cfg = mapcache_configuration_create(ctx.pool);
ctx.config = cfg;
ctx.log= mapcache_context_seeding_log;
- ctx.global_lock_aquire = dummy_lock_aquire;
- ctx.global_lock_release = dummy_lock_release;
+ ctx.global_lock_aquire = seed_lock_aquire;
+ ctx.global_lock_release = seed_lock_release;
ctx.has_threads = 1;
apr_getopt_init(&opt, ctx.pool, argc, argv);
+
+
+ apr_thread_mutex_create(&global_lock,APR_THREAD_MUTEX_UNNESTED,ctx.pool);
seededtiles=seededtilestot=queuedtilestot=0;
gettimeofday(&starttime,NULL);
More information about the mapserver-commits
mailing list