perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tors...@apache.org
Subject svn commit: r681749 - in /perl/modperl/branches/threading: ./ Changes t/apache/read3.t t/apache/read4.t t/response/TestApache/read3.pm t/response/TestApache/read4.pm xs/Apache2/RequestIO/Apache2__RequestIO.h
Date Fri, 01 Aug 2008 16:59:56 GMT
Author: torsten
Date: Fri Aug  1 09:59:55 2008
New Revision: 681749

URL: http://svn.apache.org/viewvc?rev=681749&view=rev
Log:
Merged revisions 672819,681118 via svnmerge from 
https://svn.eu.apache.org/repos/asf/perl/modperl/trunk

........
  r672819 | torsten | 2008-06-30 18:51:30 +0200 (Mon, 30 Jun 2008) | 1 line
  
  silence some "unused" warnings
........
  r681118 | torsten | 2008-07-30 18:48:12 +0200 (Wed, 30 Jul 2008) | 1 line
  
  a few enhancements to Apache2::RequestIO::read plus bugfix: read() used to clear the buffer
at end of file. Now it return 0 but does not touch the buffer
........

Added:
    perl/modperl/branches/threading/t/apache/read3.t
      - copied unchanged from r681118, perl/modperl/trunk/t/apache/read3.t
    perl/modperl/branches/threading/t/apache/read4.t
      - copied unchanged from r681118, perl/modperl/trunk/t/apache/read4.t
    perl/modperl/branches/threading/t/response/TestApache/read3.pm
      - copied unchanged from r681118, perl/modperl/trunk/t/response/TestApache/read3.pm
    perl/modperl/branches/threading/t/response/TestApache/read4.pm
      - copied unchanged from r681118, perl/modperl/trunk/t/response/TestApache/read4.pm
Modified:
    perl/modperl/branches/threading/   (props changed)
    perl/modperl/branches/threading/Changes
    perl/modperl/branches/threading/xs/Apache2/RequestIO/Apache2__RequestIO.h

Propchange: perl/modperl/branches/threading/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug  1 09:59:55 2008
@@ -1 +1 @@
-/perl/modperl/trunk:594682-672484
+/perl/modperl/trunk:594682-672484,672819-681118

Propchange: perl/modperl/branches/threading/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Aug  1 09:59:55 2008
@@ -1 +1 @@
-/perl/modperl/trunk:1-672628
+/perl/modperl/trunk:1-681650

Modified: perl/modperl/branches/threading/Changes
URL: http://svn.apache.org/viewvc/perl/modperl/branches/threading/Changes?rev=681749&r1=681748&r2=681749&view=diff
==============================================================================
--- perl/modperl/branches/threading/Changes (original)
+++ perl/modperl/branches/threading/Changes Fri Aug  1 09:59:55 2008
@@ -31,6 +31,10 @@
 
 =item 2.0.5-dev
 
+Make sure Apache2::RequestIO::read doesn't clear the buffer on end of
+file and handle negative offsets and offsets that are larger than
+the current string length. [Torsten Foertsch]
+
 Fix a problem that could make APR::XSLoader and Apache2::XSLoader
 load the wrong shared library. [Torsten Foertsch]
 

Modified: perl/modperl/branches/threading/xs/Apache2/RequestIO/Apache2__RequestIO.h
URL: http://svn.apache.org/viewvc/perl/modperl/branches/threading/xs/Apache2/RequestIO/Apache2__RequestIO.h?rev=681749&r1=681748&r2=681749&view=diff
==============================================================================
--- perl/modperl/branches/threading/xs/Apache2/RequestIO/Apache2__RequestIO.h (original)
+++ perl/modperl/branches/threading/xs/Apache2/RequestIO/Apache2__RequestIO.h Fri Aug  1 09:59:55
2008
@@ -235,28 +235,37 @@
                                          apr_off_t offset)
 {
     SSize_t total;
+    STRLEN blen;
 
     if (!SvOK(buffer)) {
         sv_setpvn(buffer, "", 0);
     }
 
+    (void)SvPV_force(buffer, blen); /* make it a valid PV */
+
     if (len <= 0) {
         Perl_croak(aTHX_ "The LENGTH argument can't be negative");
     }
 
-    /* XXX: need to handle negative offset */
-    /* XXX: need to pad with \0 if offset > size of the buffer */
+    /* handle negative offset */
+    if (offset < 0) {
+	if (-offset > (int)blen) Perl_croak(aTHX_ "Offset outside string");
+        offset += blen;
+    }
 
     mpxs_sv_grow(buffer, len+offset);
-    total = modperl_request_read(aTHX_ r, SvPVX(buffer)+offset, len);
 
-    if (total > 0) {
-        mpxs_sv_cur_set(buffer, offset+total);
-    }
-    else {
-        sv_setpvn(buffer, "", 0);
+    /* need to pad with \0 if offset > size of the buffer */
+    if (offset > SvCUR(buffer)) {
+        Zero(SvEND(buffer), offset - SvCUR(buffer), char);
     }
 
+    total = modperl_request_read(aTHX_ r, SvPVX(buffer)+offset, len);
+
+    /* modperl_request_read can return only >=0. So it's safe to do this. */
+    /* if total==0 we need to set the buffer length in case it is larger */
+    mpxs_sv_cur_set(buffer, offset+total);
+
     /* must run any set magic */
     SvSETMAGIC(buffer);
 



Mime
View raw message