cvs commit: modperl-2.0/src/modules/perl modperl_filter.c

2003-02-07 Thread stas
stas2003/02/07 20:36:35

  Modified:src/modules/perl modperl_filter.c
  Log:
  use a faster way to check whether we need to use a truncated buffer,
  strlen on an 8k buffer is not cool.
  
  Revision  ChangesPath
  1.52  +2 -1  modperl-2.0/src/modules/perl/modperl_filter.c
  
  Index: modperl_filter.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- modperl_filter.c  7 Feb 2003 02:49:01 -   1.51
  +++ modperl_filter.c  8 Feb 2003 04:36:35 -   1.52
  @@ -25,7 +25,8 @@
* XXX: if buf wasn't 'const char *buf' we could simply do
* buf[len] = '\0'
*/
  -if (len  strlen(buf)) {
  +/* MP_IOBUFSIZE is the size of wb-outbuf */
  +if (buf == wb-outbuf  len  MP_IOBUFSIZE) {
   work_buf = (char *)apr_pcalloc(wb-pool, sizeof(char*)*len);
   memcpy((void*)work_buf, buf, len);
   }
  
  
  



cvs commit: modperl-2.0/src/modules/perl modperl_filter.c

2003-02-06 Thread stas
stas2003/02/06 18:30:53

  Modified:src/modules/perl modperl_filter.c
  Log:
  we have no choice but to truncate wb-outbuf to the size of 'len'. All
  kind of weird problems pop-up when the previous request was proper and the
  current request has messed up with headers, because
  modperl_cgi_header_parse (actually the ap_scan_script_header_err_strs)
  will get things messed up because it expects a buffer with real data only.
  
  Revision  ChangesPath
  1.50  +24 -23modperl-2.0/src/modules/perl/modperl_filter.c
  
  Index: modperl_filter.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- modperl_filter.c  7 Feb 2003 00:07:42 -   1.49
  +++ modperl_filter.c  7 Feb 2003 02:30:52 -   1.50
  @@ -8,11 +8,28 @@
   apr_bucket_alloc_t *ba = (*wb-filters)-c-bucket_alloc;
   apr_bucket_brigade *bb;
   apr_bucket *bucket;
  -
  +const char *work_buf = buf;
  +
   if (wb-header_parse) {
   request_rec *r = wb-r;
   const char *bodytext = NULL;
  -int status = modperl_cgi_header_parse(r, (char *)buf, bodytext);
  +int status;
  +/*
  + * since wb-outcnt is persistent between requests, if the
  + * current response is shorter than the size of wb-outcnt
  + * it may include data from the previous request at the
  + * end. When this function receives a pointer to
  + * wb-outbuf as 'buf', modperl_cgi_header_parse may
  + * return that irrelevant data as part of 'bodytext'. So
  + * to avoid this risk, we create a new buffer of size 'len'
  + * XXX: if buf wasn't 'const char *buf' we could simply do
  + * buf[len] = '\0'
  + */
  +if (len  strlen(buf)) {
  +work_buf = (char *)apr_pcalloc(wb-pool, sizeof(char*)*len);
  +memcpy((void*)work_buf, buf, len);
  +}
  +status = modperl_cgi_header_parse(r, (char *)work_buf, bodytext);
   
   wb-header_parse = 0; /* only once per-request */
   
  @@ -26,32 +43,16 @@
   /* XXX: bodytext == NULL here */
   return status;
   }
  -
  -if (!bodytext) {
  +else if (!bodytext) {
   return APR_SUCCESS;
   }
  -else {
  -len -= (bodytext - buf);
  -buf = bodytext;
  -/*
  - * since wb-outbuf is persistent between requests, if the
  - * current response is shorter than the size of wb-outbuf
  - * it may include data from the previous request at the
  - * end. When this function receives a pointer to
  - * wb-outbuf as 'buf', modperl_cgi_header_parse may
  - * return that irrelevant data as part of 'bodytext'. So
  - * to avoid this risk, we check whether there is any real
  - * data to send and if not return.
  - */
  -if (!len) {
  -return APR_SUCCESS;
  -}
  -}
  -
  +
  +len -= (bodytext - work_buf);
  +work_buf = bodytext;
   }
   
   bb = apr_brigade_create(wb-pool, ba);
  -bucket = apr_bucket_transient_create(buf, len, ba);
  +bucket = apr_bucket_transient_create(work_buf, len, ba);
   APR_BRIGADE_INSERT_TAIL(bb, bucket);
   
   MP_TRACE_f(MP_FUNC, buffer length=%d\n, len);
  
  
  



cvs commit: modperl-2.0/src/modules/perl modperl_filter.c

2002-08-19 Thread dougm

dougm   2002/08/19 13:07:01

  Modified:.Changes
   src/modules/perl modperl_filter.c
  Log:
  fix PerlOptions +ParseHeaders to only parse once per-request
  
  Revision  ChangesPath
  1.35  +2 -0  modperl-2.0/Changes
  
  Index: Changes
  ===
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Changes   19 Aug 2002 20:02:24 -  1.34
  +++ Changes   19 Aug 2002 20:07:01 -  1.35
   -10,6 +10,8 
   
   =item 1.99_05-dev
   
  +fix PerlOptions +ParseHeaders to only parse once per-request
  +
   add external redirects Registry tests [Stas Bekman]
   
   get rid of the compat layer in ModPerl-Registry [Stas Bekman]
  
  
  
  1.38  +2 -0  modperl-2.0/src/modules/perl/modperl_filter.c
  
  Index: modperl_filter.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- modperl_filter.c  14 Aug 2002 14:54:47 -  1.37
  +++ modperl_filter.c  19 Aug 2002 20:07:01 -  1.38
   -14,6 +14,8 
   const char *bodytext = NULL;
   int status = modperl_cgi_header_parse(r, (char *)buf, bodytext);
   
  +wb-header_parse = 0; /* only once per-request */
  +
   if (status == HTTP_MOVED_TEMPORARILY) {
   return APR_SUCCESS; /* XXX: HTTP_MOVED_TEMPORARILY ? */
   }