INN commit: trunk (include/ppport.h innd/perl.c)
INN Commit
Russ_Allbery at isc.org
Tue Aug 5 19:37:38 UTC 2008
Date: Tuesday, August 5, 2008 @ 12:37:38
Author: iulius
Revision: 7950
Fix the correct handling of bodies (Perl regexps were sometimes
not properly working on SV * bodies). We now use a shared string.
For Perl < 5.7.1, fall back to a copy of such bodies. At least,
that method is reliable, even though it were 17% slower.
Add support for PERL_REVISION (default to 5 because if it is not
defined, it must be 5 -- Perl 6 defines it).
Modified:
trunk/include/ppport.h
trunk/innd/perl.c
------------------+
include/ppport.h | 5 +++--
innd/perl.c | 29 ++++++++++++-----------------
2 files changed, 15 insertions(+), 19 deletions(-)
Modified: include/ppport.h
===================================================================
--- include/ppport.h 2008-08-05 19:32:57 UTC (rev 7949)
+++ include/ppport.h 2008-08-05 19:37:38 UTC (rev 7950)
@@ -150,6 +150,7 @@
# endif
#endif
#ifndef PERL_VERSION
+# define PERL_REVISION (5)
# ifdef PERL_PATCHLEVEL
# define PERL_VERSION PERL_PATCHLEVEL
# else
@@ -162,7 +163,7 @@
# define ERRSV perl_get_sv("@",false)
#endif
-#if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 4))
+#if (PERL_REVISION == 5) && ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 4)))
# define PL_sv_undef sv_undef
# define PL_sv_yes sv_yes
# define PL_sv_no sv_no
@@ -174,7 +175,7 @@
# define PL_copline copline
#endif
-#if (PERL_VERSION < 5)
+#if (PERL_REVISION == 5) && (PERL_VERSION < 5)
# undef dTHR
# ifdef WIN32
# define dTHR extern int Perl___notused
Modified: innd/perl.c
===================================================================
--- innd/perl.c 2008-08-05 19:32:57 UTC (rev 7949)
+++ innd/perl.c 2008-08-05 19:37:38 UTC (rev 7950)
@@ -69,7 +69,6 @@
CV * filter;
int i, rc;
char * p;
- static SV * body = NULL;
static char buf[256];
if (!PerlFilterActive) return NULL;
@@ -86,23 +85,19 @@
}
/* Store the article body. We don't want to make another copy of it,
- since it could potentially be quite large. Instead, stash the
- pointer in the static SV * body. We set LEN to 0 and inc the
- refcount to tell Perl not to free it (either one should be enough).
- Requires 5.004. In testing, this produced a 17% speed improvement
- over making a copy of the article body for a fairly heavy filter. */
+ since it could potentially be quite large. In testing, this produced
+ a 17% speed improvement over making a copy of the article body
+ for a fairly heavy filter.
+ Available since Perl 5.7.1, newSVpvn_share allows to avoid such
+ a copy (getting round its use for older versions of Perl leads
+ to unreliable SV * bodies as for regexps). And for Perl not to
+ compute a hash for artBody, we give it "42". */
if (artBody) {
- if (!body) {
- body = newSV(0);
- (void) SvUPGRADE(body, SVt_PV);
- }
- SvPVX(body) = artBody;
- SvCUR_set(body, artLen);
- SvLEN_set(body, 0);
- SvPOK_on(body);
- (void) SvREADONLY_on(body);
- (void) SvREFCNT_inc(body);
- hv_store(hdr, "__BODY__", 8, body, 0);
+#if (PERL_REVISION == 5) && ((PERL_VERSION < 7) || ((PERL_VERSION == 7) && (PERL_SUBVERSION < 1)))
+ hv_store(hdr, "__BODY__", 8, newSVpv(artBody, artLen), 0);
+#else
+ hv_store(hdr, "__BODY__", 8, newSVpvn_share(artBody, artLen, 42), 0);
+#endif /* Perl < 5.7.1 */
}
hv_store(hdr, "__LINES__", 9, newSViv(lines), 0);
More information about the inn-committers
mailing list