[mapserver-commits] r12153 - in trunk/mapserver/mapcache: . include
src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:02:25 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:02:25 -0700 (Fri, 26 Aug 2011)
New Revision: 12153
Added:
trunk/mapserver/mapcache/src/fastcgi_geocache.c
Modified:
trunk/mapserver/mapcache/Makefile.in
trunk/mapserver/mapcache/Makefile.inc.in
trunk/mapserver/mapcache/include/errors.h
trunk/mapserver/mapcache/include/geocache.h
trunk/mapserver/mapcache/src/Makefile
trunk/mapserver/mapcache/src/http.c
trunk/mapserver/mapcache/src/mod_geocache.c
trunk/mapserver/mapcache/src/tileset.c
trunk/mapserver/mapcache/src/util.c
Log:
user supplied -O takes precedence on -O2
thomas.bonfort | 2010-11-05 12:38:00 +0100 (Fri, 05 Nov 2010)
Modified: trunk/mapserver/mapcache/Makefile.in
===================================================================
--- trunk/mapserver/mapcache/Makefile.in 2011-08-26 11:02:16 UTC (rev 12152)
+++ trunk/mapserver/mapcache/Makefile.in 2011-08-26 11:02:25 UTC (rev 12153)
@@ -8,14 +8,14 @@
install: .header
cd src; make install
-.header: include/geocache.h include/util.h
+.header: include/geocache.h include/util.h include/errors.h
$(MAKE) clean
touch .header
force_look:
true
-src/.libs/mod_geocache.so: src/mod_geocache.c $(SRCS) include/geocache.h
+src/.libs/mod_geocache.so: src/mod_geocache.c $(SRCS)
$(APXS) -Wc,"$(CFLAGS)" -Iinclude $(JPEG_INC) $(PNG_INC) $(CURL_CFLAGS) $(XML2_CFLAGS) $(XML2_LIBS) $(CURL_LIBS) $(JPEG_LIB) $(PNG_LIB) -c src/mod_geocache.c $(SRCS)
#install: src/.libs/mod_geocache.so
Modified: trunk/mapserver/mapcache/Makefile.inc.in
===================================================================
--- trunk/mapserver/mapcache/Makefile.inc.in 2011-08-26 11:02:16 UTC (rev 12152)
+++ trunk/mapserver/mapcache/Makefile.inc.in 2011-08-26 11:02:25 UTC (rev 12153)
@@ -18,5 +18,5 @@
-OBJS=$(shell find . -regex '^.*\.c$$' -print | grep -v mod_geocache.c | sed "s/^\(.*\)\.c$$/\1.o/")
-LOBJS=$(shell find . -regex '^.*\.c$$' -print | grep -v mod_geocache.c | sed "s/^\(.*\)\.c$$/\1.lo/")
+OBJS=$(shell find . -regex '^.*\.c$$' -print | grep -v mod_geocache.c | grep -v fastcgi_geocache.c |sed "s/^\(.*\)\.c$$/\1.o/")
+LOBJS=$(shell find . -regex '^.*\.c$$' -print | grep -v mod_geocache.c | grep -v fastcgi_geocache.c | sed "s/^\(.*\)\.c$$/\1.lo/")
Modified: trunk/mapserver/mapcache/include/errors.h
===================================================================
--- trunk/mapserver/mapcache/include/errors.h 2011-08-26 11:02:16 UTC (rev 12152)
+++ trunk/mapserver/mapcache/include/errors.h 2011-08-26 11:02:25 UTC (rev 12153)
@@ -25,7 +25,8 @@
GEOCACHE_HTTP_ERROR,
GEOCACHE_IMAGE_ERROR,
GEOCACHE_SOURCE_WMS_ERROR,
-GEOCACHE_TILESET_ERROR
+GEOCACHE_TILESET_ERROR,
+GEOCACHE_MUTEX_ERROR
} geocache_error_code;
typedef enum {
Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:02:16 UTC (rev 12152)
+++ trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:02:25 UTC (rev 12153)
@@ -25,15 +25,12 @@
#include <apr_tables.h>
#include <apr_hash.h>
#include <apr_global_mutex.h>
-#include <httpd.h>
-#include <http_config.h>
#include <libxml/tree.h>
#include "util.h"
#include "errors.h"
#include <assert.h>
#include <apr_time.h>
-
#define GEOCACHE_SUCCESS 0
#define GEOCACHE_FAILURE 1
#define GEOCACHE_TRUE 1
@@ -69,7 +66,6 @@
typedef struct geocache_image geocache_image;
typedef struct geocache_context geocache_context;
-extern module AP_MODULE_DECLARE_DATA geocache_module;
/** \defgroup utility Utility */
@@ -131,7 +127,7 @@
* calling this function after an unsuccessful call to global_lock_aquire() or from a different thread
* or process that has called global_lock_aquire() has undefined behavior
*/
- void (*global_lock_release)(geocache_context *c);
+ int (*global_lock_release)(geocache_context *c);
apr_pool_t *pool;
char *_errmsg;
Modified: trunk/mapserver/mapcache/src/Makefile
===================================================================
--- trunk/mapserver/mapcache/src/Makefile 2011-08-26 11:02:16 UTC (rev 12152)
+++ trunk/mapserver/mapcache/src/Makefile 2011-08-26 11:02:25 UTC (rev 12153)
@@ -1,6 +1,6 @@
include ../Makefile.inc
-all: .libs/mod_geocache.so
+all: .libs/mod_geocache.so geocache.fcgi
install: .libs/mod_geocache.so
$(APXS) -i -a -n geocache mod_geocache.la
@@ -11,6 +11,9 @@
mod_geocache.o: mod_geocache.c $(OBJS)
$(APXS) -Wc,"$(CFLAGS)" -I../include $(JPEG_INC) $(PNG_INC) $(CURL_CFLAGS) $(XML2_CFLAGS) $(XML2_LIBS) $(CURL_LIBS) $(JPEG_LIB) $(PNG_LIB) -c mod_geocache.c $(LOBJS)
+geocache.fcgi: fastcgi_geocache.c $(OBJS)
+ $(CC) -o geocache.fcgi -I../include $(XML2_CFLAGS) -DLINUX=2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -I/usr/include/apr-1.0 -I/usr/include/openssl -I/usr/include/xmltok -pthread $(XML2_LIBS) $(CURL_LIBS) $(JPEG_LIB) $(PNG_LIB) -lapr-1 -lfcgi fastcgi_geocache.c $(OBJS)
+
.libs/mod_geocache.so: mod_geocache.o $(OBJS)
@@ -22,4 +25,5 @@
rm -rf .libs
rm -f *.la
rm -f *.sla
+ rm -f geocache.fcgi
Added: trunk/mapserver/mapcache/src/fastcgi_geocache.c
===================================================================
--- trunk/mapserver/mapcache/src/fastcgi_geocache.c (rev 0)
+++ trunk/mapserver/mapcache/src/fastcgi_geocache.c 2011-08-26 11:02:25 UTC (rev 12153)
@@ -0,0 +1,239 @@
+/*
+ * Copyright 2010 Thomas Bonfort
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "geocache.h"
+#include <fcgiapp.h>
+#include <stdlib.h>
+#include <apr_strings.h>
+#include <apr_pools.h>
+#include <apr_proc_mutex.h>
+
+typedef struct geocache_context_fcgi geocache_context_fcgi;
+typedef struct geocache_context_fcgi_request geocache_context_fcgi_request;
+
+struct geocache_context_fcgi {
+ geocache_context ctx;
+ apr_proc_mutex_t *mutex;
+};
+
+struct geocache_context_fcgi_request {
+ geocache_context_fcgi ctx;
+ FCGX_Stream *out;
+ FCGX_Stream *err;
+};
+
+void fcgi_context_set_error(geocache_context *c, geocache_error_code code, char *message, ...) {
+ va_list args;
+ va_start(args,message);
+ c->_errmsg = apr_pvsprintf(c->pool,message,args);
+ c->_errcode = code;
+}
+
+
+int fcgi_context_get_error(geocache_context *c) {
+ return c->_errcode;
+}
+
+char* fcgi_context_get_error_message(geocache_context *c) {
+ return c->_errmsg;
+}
+
+void fcgi_context_log(geocache_context *c, geocache_log_level level, char *message, ...) {
+ va_list args;
+ va_start(args,message);
+ fprintf(stderr,"%s\n",apr_pvsprintf(c->pool,message,args));
+}
+
+void fcgi_request_context_log(geocache_context *c, geocache_log_level level, char *message, ...) {
+ va_list args;
+ va_start(args,message);
+ FCGX_FPrintF(((geocache_context_fcgi_request*)c)->err,"%s\n",apr_pvsprintf(c->pool,message,args));
+}
+
+
+
+void init_fcgi_context(geocache_context_fcgi *ctx) {
+ ctx->ctx.set_error = fcgi_context_set_error;
+ ctx->ctx.get_error = fcgi_context_get_error;
+ ctx->ctx.get_error_message = fcgi_context_get_error_message;
+ ctx->ctx.log = fcgi_context_log;
+}
+
+int geocache_fcgi_mutex_aquire(geocache_context *r, int nonblocking) {
+ int ret;
+ geocache_context_fcgi_request *ctx = (geocache_context_fcgi_request*)r;
+ ret = apr_proc_mutex_lock(ctx->ctx.mutex);
+ if(ret != APR_SUCCESS) {
+ r->set_error(r, GEOCACHE_MUTEX_ERROR, "failed to aquire mutex lock");
+ return GEOCACHE_FAILURE;
+ }
+ apr_pool_cleanup_register(r->pool, ctx->ctx.mutex, (void*)apr_proc_mutex_unlock, apr_pool_cleanup_null);
+
+ return GEOCACHE_SUCCESS;
+}
+
+int geocache_fcgi_mutex_release(geocache_context *r) {
+ int ret;
+ geocache_context_fcgi_request *ctx = (geocache_context_fcgi_request*)r;
+ ret = apr_proc_mutex_unlock(ctx->ctx.mutex);
+ if(ret != APR_SUCCESS) {
+ r->set_error(r, GEOCACHE_MUTEX_ERROR, "failed to release mutex");
+ return GEOCACHE_FAILURE;
+ }
+ apr_pool_cleanup_kill(r->pool, ctx->ctx.mutex, (void*)apr_proc_mutex_unlock);
+ return GEOCACHE_SUCCESS;
+}
+
+void init_fcgi_request_context(geocache_context_fcgi_request *ctx) {
+ init_fcgi_context((geocache_context_fcgi*)ctx);
+ ctx->ctx.ctx.global_lock_aquire = geocache_fcgi_mutex_aquire;
+ ctx->ctx.ctx.global_lock_release = geocache_fcgi_mutex_release;
+}
+
+static geocache_context_fcgi* fcgi_context_create() {
+ int ret;
+ apr_pool_t *pool;
+ apr_pool_create_core(&pool);
+ geocache_context_fcgi *ctx = apr_pcalloc(pool, sizeof(geocache_context_fcgi));
+ ctx->ctx.pool = pool;
+ init_fcgi_context(ctx);
+ ret = apr_proc_mutex_create(&ctx->mutex,"/tmp/geocache.mutex",APR_LOCK_PROC_PTHREAD,pool);
+ if(ret != APR_SUCCESS) {
+ ctx->ctx.set_error(&ctx->ctx,GEOCACHE_MUTEX_ERROR,"failed to created mutex");
+ } else {
+ apr_pool_cleanup_register(pool,ctx->mutex,(void*)apr_proc_mutex_destroy, apr_pool_cleanup_null);
+ }
+ return ctx;
+}
+
+static geocache_context_fcgi_request* fcgi_context_request_create(geocache_context_fcgi *parent, FCGX_Stream *out, FCGX_Stream *err) {
+ apr_pool_t *pool;
+ apr_pool_create(&pool,parent->ctx.pool);
+ geocache_context_fcgi_request *ctx = apr_pcalloc(pool, sizeof(geocache_context_fcgi_request));
+ ctx->ctx.ctx.pool = pool;
+ ctx->ctx.mutex = parent->mutex;
+ ctx->out = out;
+ ctx->err = err;
+ init_fcgi_request_context(ctx);
+ return ctx;
+}
+
+
+
+static int geocache_write_tile(geocache_context_fcgi_request *ctx, geocache_tile *tile) {
+ int rc;
+
+ if(tile->tileset->format) {
+ if(!strcmp(tile->tileset->format->extension,"png"))
+ FCGX_FPrintF(ctx->out,"Content-type: image/png\r\n\r\n");
+ else
+ FCGX_FPrintF(ctx->out,"Content-type: image/jpeg\r\n\r\n");
+ } else {
+ geocache_image_format_type t = geocache_imageio_header_sniff((geocache_context*)ctx,tile->data);
+ if(t == GC_PNG)
+ FCGX_FPrintF(ctx->out,"Content-type: image/png\r\n\r\n");
+ else if(t == GC_JPEG)
+ FCGX_FPrintF(ctx->out,"Content-type: image/jpeg\r\n\r\n");
+ else {
+ return 500;
+ }
+ }
+ FCGX_PutStr(tile->data->buf, tile->data->size,ctx->out);
+
+ return 200;
+}
+
+int main(int argc, char **argv) {
+
+ apr_pool_initialize();
+ char *msg;
+ geocache_context_fcgi* globalctx = fcgi_context_create();
+ geocache_context* c = (geocache_context*)globalctx;
+ geocache_cfg *cfg = geocache_configuration_create(c->pool);
+ FCGX_Stream *in, *out, *err;
+ FCGX_ParamArray envp;
+
+ FCGX_Init();
+
+ char *conffile = getenv("GEOCACHE_CONFIG_FILE");
+ if(!conffile) {
+ c->log(c,GEOCACHE_ERROR,"no config file found in GEOCACHE_CONFIG_FILE envirronement");
+ return 1;
+ }
+ c->log(c,GEOCACHE_DEBUG,"geocache fcgi conf file: %s",conffile);
+ msg = geocache_configuration_parse(conffile,cfg,c);
+ if(msg) {
+ c->log(c,GEOCACHE_ERROR,"failed to parse %s: %s",conffile,msg);
+ return 1;
+ }
+
+ while (FCGX_Accept(&in, &out, &err, &envp) >= 0) {
+ apr_table_t *params;
+ geocache_context *ctx = (geocache_context*) fcgi_context_request_create(globalctx,out,err);
+ geocache_tile *tile;
+ geocache_request *request;
+ char *pathInfo = FCGX_GetParam("PATH_INFO",envp);
+
+ int i;
+
+
+ params = geocache_http_parse_param_string((geocache_context*)ctx, FCGX_GetParam("QUERY_STRING",envp));
+
+ for(i=0;i<GEOCACHE_SERVICES_COUNT;i++) {
+ geocache_service *service = cfg->services[i];
+ if(!service) continue;
+ request = service->parse_request(ctx,pathInfo,params,cfg);
+ if(request)
+ break;
+ }
+ if(!request || !request->ntiles) {
+ FCGX_FPrintF(out,"Status: 404 Not Found\r\n\r\n");
+ goto cleanup;
+ }
+
+ for(i=0;i<request->ntiles;i++) {
+ geocache_tile *tile = request->tiles[i];
+ int rv = geocache_tileset_tile_get(tile,ctx);
+ if(rv != GEOCACHE_SUCCESS) {
+ ctx->log(c,GEOCACHE_DEBUG,c->get_error_message(ctx));
+ FCGX_FPrintF(out,"Status: 500 Internal Server Error\r\n\r\n");
+ goto cleanup;
+ }
+ }
+ if(request->ntiles == 1) {
+ tile = request->tiles[0];
+ } else {
+ tile = geocache_image_merge_tiles(ctx,cfg->merge_format,request->tiles,request->ntiles);
+ if(!tile) {
+ ctx->log(ctx,GEOCACHE_ERROR, "tile merging failed to return data");
+ if(ctx->get_error(ctx)) {
+ ctx->log(ctx,GEOCACHE_ERROR,c->get_error_message(ctx));
+ FCGX_FPrintF(out,"Status: 500 Internal Server Error\r\n\r\n");
+ goto cleanup;
+ }
+ FCGX_FPrintF(out,"Status: 500 Internal Server Error\r\n\r\n");
+ goto cleanup;
+ }
+ tile->tileset = request->tiles[0]->tileset;
+ }
+ geocache_write_tile((geocache_context_fcgi_request*)ctx,tile);
+cleanup:
+ apr_pool_destroy(ctx->pool);
+ }
+ apr_pool_destroy(globalctx->ctx.pool);
+
+
+}
Modified: trunk/mapserver/mapcache/src/http.c
===================================================================
--- trunk/mapserver/mapcache/src/http.c 2011-08-26 11:02:16 UTC (rev 12152)
+++ trunk/mapserver/mapcache/src/http.c 2011-08-26 11:02:25 UTC (rev 12153)
@@ -18,8 +18,9 @@
#include <curl/curl.h>
#include <apr_hash.h>
#include <apr_strings.h>
-#include <stdio.h>
+#include <ctype.h>
+#define MAX_STRING_LEN 10000
size_t _geocache_curl_memory_callback(void *ptr, size_t size, size_t nmemb, void *data) {
geocache_buffer *buffer = (geocache_buffer*)data;
@@ -42,7 +43,7 @@
/* we pass our geocache_buffer struct to the callback function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)data);
-
+
curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, error_msg);
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1);
@@ -89,6 +90,62 @@
#undef _mystr
}
+static char _geocache_x2c(const char *what)
+{
+ register char digit;
+ digit = ((what[0] >= 'A') ? ((what[0] & 0xdf) - 'A') + 10
+ : (what[0] - '0'));
+ digit *= 16;
+ digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A') + 10
+ : (what[1] - '0'));
+ return (digit);
+}
+
+#ifdef _WIN32
+#define IS_SLASH(s) ((s == '/') || (s == '\\'))
+#else
+#define IS_SLASH(s) (s == '/')
+#endif
+
+int _geocache_unescape_url(char *url) {
+ register int badesc, badpath;
+ char *x, *y;
+
+ badesc = 0;
+ badpath = 0;
+ /* Initial scan for first '%'. Don't bother writing values before
+ * seeing a '%' */
+ y = strchr(url, '%');
+ if (y == NULL) {
+ return GEOCACHE_SUCCESS;
+ }
+ for (x = y; *y; ++x, ++y) {
+ if (*y != '%')
+ *x = *y;
+ else {
+ if (!isxdigit(*(y + 1)) || !isxdigit(*(y + 2))) {
+ badesc = 1;
+ *x = '%';
+ }
+ else {
+ *x = _geocache_x2c(y + 1);
+ y += 2;
+ if (IS_SLASH(*x) || *x == '\0')
+ badpath = 1;
+ }
+ }
+ }
+ *x = '\0';
+ if (badesc)
+ return GEOCACHE_FAILURE;
+ else if (badpath)
+ return GEOCACHE_FAILURE;
+ else
+ return GEOCACHE_SUCCESS;
+}
+
+
+
char* geocache_http_build_url(geocache_context *r, char *base, apr_table_t *params) {
if(!apr_is_empty_table(params)) {
int stringLength = 0, baseLength;
@@ -152,12 +209,12 @@
value = strchr(key, '=');
if (value) {
*value++ = '\0'; /* replace '=' by \0, thus terminating the key string */
- ap_unescape_url(key);
- ap_unescape_url(value);
+ _geocache_unescape_url(key);
+ _geocache_unescape_url(value);
}
else {
value = "";
- ap_unescape_url(key);
+ _geocache_unescape_url(key);
}
/* Store key/value pair in our form hash. */
apr_table_addn(params, key, value);
Modified: trunk/mapserver/mapcache/src/mod_geocache.c
===================================================================
--- trunk/mapserver/mapcache/src/mod_geocache.c 2011-08-26 11:02:16 UTC (rev 12152)
+++ trunk/mapserver/mapcache/src/mod_geocache.c 2011-08-26 11:02:25 UTC (rev 12153)
@@ -30,6 +30,9 @@
#include "unixd.h"
#endif
+module AP_MODULE_DECLARE_DATA geocache_module;
+
+
static char* geocache_mutex_name = "geocache_mutex";
typedef struct geocache_context_apache geocache_context_apache;
@@ -57,6 +60,7 @@
va_start(args,message);
c->_errmsg = apr_pvsprintf(c->pool,message,args);
c->_errcode = code;
+ va_end(args);
}
@@ -73,6 +77,7 @@
va_list args;
va_start(args,message);
ap_log_error(APLOG_MARK, APLOG_INFO, 0, ctx->server,"%s",apr_pvsprintf(ctx->ctx.ctx.pool,message,args));
+ va_end(args);
}
void apache_context_request_log(geocache_context *c, geocache_log_level level, char *message, ...) {
@@ -80,6 +85,7 @@
va_list args;
va_start(args,message);
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, ctx->request,"%s",apr_pvsprintf(ctx->ctx.ctx.pool,message,args));
+ va_end(args);
}
void init_apache_context(geocache_context_apache *ctx) {
@@ -115,33 +121,24 @@
}
void init_apache_request_context(geocache_context_apache_request *ctx) {
- init_apache_context(ctx);
+ init_apache_context((geocache_context_apache*)ctx);
ctx->ctx.ctx.log = apache_context_request_log;
ctx->ctx.ctx.global_lock_aquire = geocache_util_mutex_aquire;
ctx->ctx.ctx.global_lock_release = geocache_util_mutex_release;
}
void init_apache_server_context(geocache_context_apache_server *ctx) {
- init_apache_context(ctx);
+ init_apache_context((geocache_context_apache*)ctx);
ctx->ctx.ctx.log = apache_context_server_log;
ctx->ctx.ctx.global_lock_aquire = geocache_util_mutex_aquire;
ctx->ctx.ctx.global_lock_release = geocache_util_mutex_release;
}
-
-
-static geocache_context_apache* apache_context_create(apr_pool_t *pool) {
- geocache_context_apache *ctx = apr_pcalloc(pool, sizeof(geocache_context_apache));
- ctx->ctx.pool = pool;
- init_apache_context(ctx);
- return ctx;
-}
-
static geocache_context_apache_request* apache_request_context_create(request_rec *r) {
geocache_context_apache_request *ctx = apr_pcalloc(r->pool, sizeof(geocache_context_apache_request));
ctx->ctx.ctx.pool = r->pool;
ctx->request = r;
- init_apache_server_context(ctx);
+ init_apache_request_context(ctx);
return ctx;
}
@@ -202,6 +199,7 @@
geocache_cfg *config = NULL;
geocache_request *request;
geocache_context_apache_request *ctx = apache_request_context_create(r);
+ geocache_context *c = (geocache_context*)ctx;
geocache_tile *tile;
int i;
@@ -212,14 +210,14 @@
return HTTP_METHOD_NOT_ALLOWED;
}
- params = geocache_http_parse_param_string((geocache_context*)ctx, r->args);
+ params = geocache_http_parse_param_string(c, r->args);
config = ap_get_module_config(r->per_dir_config, &geocache_module);
for(i=0;i<GEOCACHE_SERVICES_COUNT;i++) {
/* loop through the services that have been configured */
geocache_service *service = config->services[i];
if(!service) continue;
- request = service->parse_request((geocache_context*)ctx,r->path_info,params,config);
+ request = service->parse_request(c,r->path_info,params,config);
/* the service has recognized the request if it returns a non NULL value */
if(request)
break;
@@ -231,8 +229,9 @@
for(i=0;i<request->ntiles;i++) {
geocache_tile *tile = request->tiles[i];
- int rv = geocache_tileset_tile_get(tile, (geocache_context*)ctx);
+ int rv = geocache_tileset_tile_get(tile, c);
if(rv != GEOCACHE_SUCCESS) {
+ c->log(c,c->get_error(c),c->get_error_message(c));
return HTTP_NOT_FOUND;
}
}
Modified: trunk/mapserver/mapcache/src/tileset.c
===================================================================
--- trunk/mapserver/mapcache/src/tileset.c 2011-08-26 11:02:16 UTC (rev 12152)
+++ trunk/mapserver/mapcache/src/tileset.c 2011-08-26 11:02:25 UTC (rev 12153)
@@ -59,12 +59,22 @@
/*
* for each of the metatile's tiles, ask the underlying cache to lock it
*/
-void _geocache_tileset_metatile_lock(geocache_metatile *mt, geocache_context *r) {
- int i;
+int _geocache_tileset_metatile_lock(geocache_metatile *mt, geocache_context *r) {
+ int i,ret;
for(i=0; i<mt->ntiles; i++) {
geocache_tile *tile = &(mt->tiles[i]);
- mt->tile.tileset->cache->tile_lock(tile,r);
+ ret = mt->tile.tileset->cache->tile_lock(tile,r);
+ if(ret != GEOCACHE_SUCCESS) {
+ /* undo successful locks */
+ int j;
+ for(j=0;j<i;j++) {
+ tile = &(mt->tiles[j]);
+ mt->tile.tileset->cache->tile_unlock(tile,r);
+ }
+ return ret;
+ }
}
+ return GEOCACHE_SUCCESS;
}
/*
@@ -237,7 +247,12 @@
if(isLocked == GEOCACHE_FALSE) {
/* no other thread is doing the rendering, we aquire and lock a list of tiles to render */
mt = _geocache_tileset_metatile_get(tile,r);
- _geocache_tileset_metatile_lock(mt,r);
+ ret = _geocache_tileset_metatile_lock(mt,r);
+ if(ret != GEOCACHE_SUCCESS) {
+ r->set_error(r,GEOCACHE_TILESET_ERROR,"failed to lock tiles. do you have write permission?");
+ r->global_lock_release(r);
+ return ret;
+ }
}
r->global_lock_release(r);
Modified: trunk/mapserver/mapcache/src/util.c
===================================================================
--- trunk/mapserver/mapcache/src/util.c 2011-08-26 11:02:16 UTC (rev 12152)
+++ trunk/mapserver/mapcache/src/util.c 2011-08-26 11:02:25 UTC (rev 12153)
@@ -17,6 +17,7 @@
#include <geocache.h>
#include <apr_strings.h>
#include <apr_tables.h>
+#include <curl/curl.h>
int geocache_util_extract_int_list(char* args, const char sep, int **numbers,
int *numbers_count, geocache_context *r) {
@@ -64,6 +65,12 @@
return GEOCACHE_SUCCESS;
}
+void geocache_context_init_parent(geocache_context *ctx) {
+ curl_global_init(CURL_GLOBAL_ALL);
+}
+
+void geocache_context_init(geocache_context *ctx, geocache_context *parent);
+
/*
int geocache_util_mutex_aquire(geocache_context *r) {
int ret;
More information about the mapserver-commits
mailing list