[mapserver-commits] r13025 - trunk/mapserver/mapcache/nginx

svn at osgeo.org svn at osgeo.org
Thu Feb 2 06:55:00 EST 2012


Author: tbonfort
Date: 2012-02-02 03:55:00 -0800 (Thu, 02 Feb 2012)
New Revision: 13025

Modified:
   trunk/mapserver/mapcache/nginx/ngx_http_mapcache_module.c
Log:
copy the response buffer so we can safely destroy the apr pool


Modified: trunk/mapserver/mapcache/nginx/ngx_http_mapcache_module.c
===================================================================
--- trunk/mapserver/mapcache/nginx/ngx_http_mapcache_module.c	2012-02-01 13:13:07 UTC (rev 13024)
+++ trunk/mapserver/mapcache/nginx/ngx_http_mapcache_module.c	2012-02-02 11:55:00 UTC (rev 13025)
@@ -20,13 +20,11 @@
       ngx_null_command
 };
 
-/*
 static void
 ngx_http_mapcache_cleanup(void *data)
 {
    apr_pool_destroy((apr_pool_t*)data);
 }
-*/
 
 typedef struct {
    mapcache_context ctx;
@@ -121,8 +119,13 @@
    if(response->data) {
       r->headers_out.content_length_n = response->data->size;
    }
+   int rc;
    r->headers_out.status = response->code;
-   ngx_http_send_header(r);
+   rc = ngx_http_send_header(r);
+   if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
+      return;
+   }
+
    if(response->data) {
       ngx_buf_t    *b;
       ngx_chain_t   out;
@@ -133,27 +136,15 @@
          return;
       }
 
-      /* steal the buffer's data and associate our own cleanup function to it
-      ngx_pool_cleanup_t     *cln;
-      cln = ngx_pool_cleanup_add(r->pool, 0);
-      cln->handler = free;
-      cln->data = response->data->buf ;
-      apr_pool_cleanup_kill(response->data->pool, response->data->buf, (void*)free) ;
-      */
-      b->pos = response->data->buf;
+      b->pos = ngx_pcalloc(r->pool,response->data->size);
+      memcpy(b->pos,response->data->buf,response->data->size);
       b->last = b->pos + response->data->size;
       b->memory = 1;
       b->last_buf = 1;
       b->flush = 1;
-      ngx_blocking(r->connection->fd);
       out.buf = b;
       out.next = NULL;
-      int rc;
-      do {
-         rc = ngx_http_output_filter(r, &out);
-         r->connection->write->ready = 1;
-      } while (rc == NGX_AGAIN && !ngx_quit && !ngx_terminate);
-      ngx_nonblocking(r->connection->fd);
+      ngx_http_output_filter(r, &out);
    }
 
 }
@@ -204,12 +195,10 @@
     apr_pool_t *main_pool = ctx->pool;
     apr_pool_create(&(ctx->pool),main_pool);
     ngctx->r = r;
-    /*
     ngx_pool_cleanup_t     *cln;
     cln = ngx_pool_cleanup_add(r->pool, 0);
     cln->handler = ngx_http_mapcache_cleanup;
     cln->data = ctx->pool;
-    */
     mapcache_request *request = NULL;
     mapcache_http_response *http_response;
 



More information about the mapserver-commits mailing list