[mapserver-commits] r12194 - in trunk/mapserver/mapcache: . src

svn at osgeo.org svn at osgeo.org
Fri Aug 26 07:05:59 EDT 2011


Author: tbonfort
Date: 2011-08-26 04:05:59 -0700 (Fri, 26 Aug 2011)
New Revision: 12194

Modified:
   trunk/mapserver/mapcache/geocache.xml
   trunk/mapserver/mapcache/src/configuration.c
   trunk/mapserver/mapcache/src/http.c
   trunk/mapserver/mapcache/src/mod_geocache.c
Log:
refactor the dispatching of incoming client requests
thomas.bonfort | 2011-01-04 13:06:57 +0100 (Tue, 04 Jan 2011)

Modified: trunk/mapserver/mapcache/geocache.xml
===================================================================
--- trunk/mapserver/mapcache/geocache.xml	2011-08-26 11:05:54 UTC (rev 12193)
+++ trunk/mapserver/mapcache/geocache.xml	2011-08-26 11:05:59 UTC (rev 12194)
@@ -1,5 +1,11 @@
 <!--comment-->
 <geocache>
+   <grid name="testgrid">
+      <srs>epsg:4326</srs>
+      <size>256 256</size>
+      <extent>-180 -90 180 90</extent>
+      <resolutions>0.1 0.05 0.025 0.0125</resolutions>
+   </grid>
     <cache name="disk" type="disk">
         <base>/tmp</base>
         <symlink_blank/>
@@ -17,7 +23,7 @@
         </wmsparams>
     </source>
     <source name="osm" type="wms">
-        <url>http://localhost/cgi-bin/mapserv</url>
+        <url>http://localhost/cgi-bin/mapserv?</url>
         <srs>epsg:900913</srs>
         <wmsparams>
             <FORMAT>image/png</FORMAT>

Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:05:54 UTC (rev 12193)
+++ trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:05:59 UTC (rev 12194)
@@ -114,7 +114,11 @@
    grid->extents = (double**)apr_pcalloc(pool,grid->levels*sizeof(double*));
    grid->resolutions = (double*)apr_pcalloc(pool,grid->levels*sizeof(double));
    for(i=0; i<grid->levels; i++) {
-      grid->extents[i] = google_extent;
+      grid->extents[i] = (double*)apr_pcalloc(pool,4*sizeof(double));
+      grid->extents[i][0] = google_extent[0];
+      grid->extents[i][1] = google_extent[1];
+      grid->extents[i][2] = google_extent[2];
+      grid->extents[i][3] = google_extent[3];
       grid->resolutions[i] = google_resolutions[i];
    }
    geocache_configuration_add_grid(cfg,grid,"google");

Modified: trunk/mapserver/mapcache/src/http.c
===================================================================
--- trunk/mapserver/mapcache/src/http.c	2011-08-26 11:05:54 UTC (rev 12193)
+++ trunk/mapserver/mapcache/src/http.c	2011-08-26 11:05:59 UTC (rev 12194)
@@ -33,13 +33,11 @@
    curl_handle = curl_easy_init();
    int ret;
    char error_msg[CURL_ERROR_SIZE];
-
-#ifdef DEBUG
-   ctx->log(ctx, GEOCACHE_DEBUG ,"##### START #####curl requesting url %s",url);
-#endif
    /* specify URL to get */
    curl_easy_setopt(curl_handle, CURLOPT_URL, url);
-
+#ifdef DEBUG
+   ctx->log(ctx, GEOCACHE_DEBUG, "##### START #####\ncurl requesting url %s",url);
+#endif
    /* send all data to this function  */ 
    curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, _geocache_curl_memory_callback);
 
@@ -69,10 +67,7 @@
 
 /* calculate the length of the string formed by key=value&, and add it to cnt */
 static APR_DECLARE_NONSTD(int) _geocache_key_value_strlen_callback(void *cnt, const char *key, const char *value) {
-   int valLength = 2;
-   if((value && *value))
-      valLength += strlen(value);
-   *((int*)cnt) += strlen(key) + valLength;
+   *((int*)cnt) += strlen(key) + 2 + ((value && *value) ? strlen(value) : 0);
    return 1;
 }
 
@@ -166,14 +161,9 @@
       }
 
       /* add final \0 and eventual separator to add ('?' or '&') */
-      stringLength += baseLength;
-      if(charToAppend) {
-         stringLength += 2;
-      } else {
-         stringLength += 1;
-      }
+      stringLength += baseLength + ((charToAppend)?2:1);
 
-      builtUrl = builtUrlPtr = apr_pcalloc(r->pool, stringLength);
+      builtUrl = builtUrlPtr = apr_palloc(r->pool, stringLength);
 
       builtUrlPtr = apr_cpystrn(builtUrlPtr,base,MAX_STRING_LEN);
       if(charToAppend)

Modified: trunk/mapserver/mapcache/src/mod_geocache.c
===================================================================
--- trunk/mapserver/mapcache/src/mod_geocache.c	2011-08-26 11:05:54 UTC (rev 12193)
+++ trunk/mapserver/mapcache/src/mod_geocache.c	2011-08-26 11:05:59 UTC (rev 12194)
@@ -87,12 +87,8 @@
    geocache_context_apache_request *ctx = (geocache_context_apache_request*)c;
    va_list args;
    va_start(args,message);
-   char *msg;
-   vasprintf(&msg,message,args);
+   ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, ctx->request, "%s", apr_pvsprintf(c->pool,message,args));
    va_end(args);
-   ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, ctx->request,"%s",msg);
-   free(msg);
-
 }
 
 void geocache_util_mutex_aquire(geocache_context *gctx) {
@@ -134,7 +130,7 @@
 
 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));
-   apr_pool_create(&ctx->ctx.ctx.pool,r->pool);
+   ctx->ctx.ctx.pool = r->pool;
    ctx->ctx.ctx.config = ap_get_module_config(r->per_dir_config, &geocache_module);
    ctx->request = r;
    init_apache_request_context(ctx);
@@ -143,7 +139,7 @@
 
 static geocache_context_apache_server* apache_server_context_create(server_rec *s, apr_pool_t *pool) {
    geocache_context_apache_server *ctx = apr_pcalloc(pool, sizeof(geocache_context_apache_server));
-   apr_pool_create(&ctx->ctx.ctx.pool,pool);
+   ctx->ctx.ctx.pool = pool;
    ctx->ctx.ctx.config = NULL;
    ctx->server = s;
    init_apache_server_context(ctx);
@@ -168,7 +164,7 @@
       apr_table_mergen(r->headers_out, "Cache-Control",apr_psprintf(r->pool, "max-age=%d", tile->expires));
       char *timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
       apr_rfc822_date(timestr, expires);
-      apr_table_setn(r->headers_out, "Expires", timestr);
+      apr_table_set(r->headers_out, "Expires", timestr);
 
    }
    ap_set_last_modified(r);
@@ -245,7 +241,6 @@
       tile->tileset = request->tiles[0]->tileset;
    }
    ret = geocache_write_tile(apache_ctx,tile);
-   apr_pool_clear(global_ctx->pool);
    return ret;
 }
 



More information about the mapserver-commits mailing list