httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject cvs commit: httpd-test/perl-framework/c-modules/test_pass_brigade mod_test_pass_brigade.c
Date Wed, 29 Sep 2004 15:03:59 GMT
jorton      2004/09/29 08:03:59

  Modified:    perl-framework/c-modules/test_pass_brigade
                        mod_test_pass_brigade.c
  Log:
  Prevent death by memory consumption in an --enable-pool-debug/-lefence
  build: allocate and {ab,re}use a single brigade structure rather than
  allocating one out of r->pool for each block sent (see also "why are
  brigades allocated out of pools this is insane" threads).
  
  Revision  Changes    Path
  1.5       +4 -1      httpd-test/perl-framework/c-modules/test_pass_brigade/mod_test_pass_brigade.c
  
  Index: mod_test_pass_brigade.c
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/c-modules/test_pass_brigade/mod_test_pass_brigade.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -d -w -u -r1.4 -r1.5
  --- mod_test_pass_brigade.c	15 Jun 2004 15:50:53 -0000	1.4
  +++ mod_test_pass_brigade.c	29 Sep 2004 15:03:59 -0000	1.5
  @@ -27,6 +27,7 @@
       size_t total=0, remaining=1;
       char *buff;
       size_t buff_size = 8192;
  +    apr_bucket_brigade *bb;
   
       if (strcmp(r->handler, "test_pass_brigade")) {
           return DECLINED;
  @@ -43,15 +44,16 @@
   
       buff = malloc(buff_size);
       memset(buff, 'a', buff_size);
  +    bb = apr_brigade_create(r->pool, c->bucket_alloc);
   
       while (total < remaining) {
           int left = (remaining - total);
           int len = left <= buff_size ? left : buff_size;
  -        apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
           apr_bucket *bucket = apr_bucket_heap_create(buff, len, NULL,
                                                       c->bucket_alloc);
           apr_status_t status;
   
  +        apr_brigade_cleanup(bb);
           APR_BRIGADE_INSERT_TAIL(bb, bucket);
   
           status = ap_pass_brigade(r->output_filters->next, bb);
  @@ -71,6 +73,7 @@
                   len, len);
       }
       
  +    apr_brigade_destroy(bb);
       fprintf(stderr,
               "[mod_test_pass_brigade] done writing %ld of %ld bytes\n",
               total, remaining);
  
  
  

Mime
View raw message