[mapserver-commits] r12979 - trunk/mapserver/mapcache/nginx
svn at osgeo.org
svn at osgeo.org
Fri Jan 6 08:16:16 EST 2012
Author: tbonfort
Date: 2012-01-06 05:16:16 -0800 (Fri, 06 Jan 2012)
New Revision: 12979
Modified:
trunk/mapserver/mapcache/nginx/ngx_http_mapcache_module.c
Log:
further nginx cleanup behavior
Modified: trunk/mapserver/mapcache/nginx/ngx_http_mapcache_module.c
===================================================================
--- trunk/mapserver/mapcache/nginx/ngx_http_mapcache_module.c 2012-01-06 10:24:00 UTC (rev 12978)
+++ trunk/mapserver/mapcache/nginx/ngx_http_mapcache_module.c 2012-01-06 13:16:16 UTC (rev 12979)
@@ -20,11 +20,13 @@
ngx_null_command
};
-
+/*
static void
ngx_http_mapcache_cleanup(void *data)
{
+ apr_pool_destroy((apr_pool_t*)data);
}
+*/
typedef struct {
mapcache_context ctx;
@@ -55,7 +57,6 @@
static void *
ngx_http_mapcache_create_conf(ngx_conf_t *cf)
{
- ngx_pool_cleanup_t *cln;
apr_pool_t *pool;
apr_initialize();
atexit(apr_terminate);
@@ -68,29 +69,14 @@
ctx->clone = ngx_mapcache_context_clone;
ctx->config = NULL;
- cln = ngx_pool_cleanup_add(cf->pool, 0);
- if (cln == NULL) {
- return NULL;
- }
- cln->handler = ngx_http_mapcache_cleanup;
- cln->data = pool;
-
return ctx;
}
static void ngx_http_mapcache_write_response(mapcache_context *ctx, ngx_http_request_t *r,
mapcache_http_response *response) {
- /*
if(response->mtime) {
- ap_update_mtime(r, response->mtime);
- char *timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
- apr_rfc822_date(timestr, response->mtime);
- //apr_table_setn(r->headers_out, "Last-Modified", timestr);
- }
- */
- if(response->mtime) {
time_t if_modified_since;
if(r->headers_in.if_modified_since) {
if_modified_since = ngx_http_parse_time(r->headers_in.if_modified_since->value.data,
@@ -146,15 +132,30 @@
"Failed to allocate response buffer.");
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->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;
- ngx_http_output_filter(r, &out);
+ 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);
}
-
+
}
@@ -203,6 +204,12 @@
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