[mapserver-commits] r12164 - trunk/mapserver/mapcache/src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:03:33 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:03:33 -0700 (Fri, 26 Aug 2011)
New Revision: 12164
Modified:
trunk/mapserver/mapcache/src/geocache_seed.c
Log:
move locking out of the cache responsibility
thomas.bonfort | 2010-12-09 10:22:28 +0100 (Thu, 09 Dec 2010)
Modified: trunk/mapserver/mapcache/src/geocache_seed.c
===================================================================
--- trunk/mapserver/mapcache/src/geocache_seed.c 2011-08-26 11:03:29 UTC (rev 12163)
+++ trunk/mapserver/mapcache/src/geocache_seed.c 2011-08-26 11:03:33 UTC (rev 12164)
@@ -2,6 +2,7 @@
#include <apr_thread_proc.h>
#include <apr_thread_mutex.h>
#include <apr_getopt.h>
+#include <signal.h>
typedef struct geocache_context_seeding geocache_context_seeding;
@@ -25,6 +26,8 @@
gc_tiles_for_zoom seed_tiles[100]; //TODO: bug here if more than 100 zoomlevels, or if multithreaded usage on multiple tilesets
+int sig_int_received = 0;
+
static const apr_getopt_option_t seed_options[] = {
/* long-option, short-option, has-arg flag, description */
{ "config", 'c', TRUE, "configuration file"},
@@ -36,6 +39,16 @@
{ NULL, 0, 0, NULL },
};
+void handle_sig_int(int signal) {
+ if(!sig_int_received) {
+ fprintf(stderr,"SIGINT received, waiting for threads to finish\n");
+ fprintf(stderr,"press ctrl-C again to force terminate, you might end up with locked tiles\n");
+ sig_int_received = 1;
+ } else {
+ exit(signal);
+ }
+}
+
void geocache_context_seeding_lock_aquire(geocache_context *gctx, int blocking) {
int ret;
geocache_context_seeding *ctx = (geocache_context_seeding*)gctx;
@@ -155,7 +168,7 @@
tile_ctx.global_lock_release = dummy_lock_release;
tile_ctx.log = geocache_context_seeding_log;
apr_pool_create(&tile_ctx.pool,NULL);
- while(GEOCACHE_SUCCESS == ctx->get_next_tile(ctx,tile,&tile_ctx)) {
+ while(GEOCACHE_SUCCESS == ctx->get_next_tile(ctx,tile,&tile_ctx) && !sig_int_received) {
geocache_tileset_tile_get(&tile_ctx,tile);
if(tile_ctx.get_error(&tile_ctx)) {
gctx->set_error(gctx,tile_ctx.get_error(&tile_ctx),tile_ctx.get_error_message(&tile_ctx));
@@ -202,6 +215,7 @@
int rv,n;
const char *optarg;
apr_initialize();
+ (void) signal(SIGINT,handle_sig_int);
apr_pool_create_core(&gctx->pool);
geocache_context_init(gctx);
cfg = geocache_configuration_create(gctx->pool);
More information about the mapserver-commits
mailing list