You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Charles Jardine <cj...@cam.ac.uk> on 2002/03/18 16:07:39 UTC
Perl 5.7.3 breaks mod_perl tied handles [PATCH]
I have been testing my mod_perl-1.26 applications under perl 5.7.3.
I have discovered that the tying of STDIN and STDOUT does not work.
This is caused by a change in the internals of the implementation
of tied handles in Perl. The following extract from the source
of Perl (pp_sys.c ll 764 ff) describes the change
methname = "TIEHANDLE";
how = PERL_MAGIC_tiedscalar;
/* For tied filehandles, we apply tiedscalar magic to the IO
slot of the GP rather than the GV itself. AMS 20010812 */
if (!GvIOp(varsv))
GvIOp(varsv) = newIO();
varsv = (SV *)GvIOp(varsv);
break;
I have got myself going by patching mod_perl as below. This
patch makes mod_perl work with 5.7.3, but, of course, stops it
working with 5.6.x. It is beyond my knowledge to make this patch
version dependent, as it needs to be.
*** /tmp/sccs.I.aOiq Mon Mar 18 14:41:11 2002
--- perlio.c Mon Mar 18 12:18:22 2002
***************
*** 54,61 ****
#define TIEHANDLE(name,obj) \
{ \
dHANDLE(name); \
! sv_unmagic((SV*)handle, 'q'); \
! sv_magic((SV*)handle, obj, 'q', Nullch, 0); \
}
#if 0
--- 54,61 ----
#define TIEHANDLE(name,obj) \
{ \
dHANDLE(name); \
! sv_unmagic((SV*)GvIOp((SV*)handle), 'q'); \
! sv_magic((SV*)GvIOp((SV*)handle), obj, 'q', Nullch, 0); \
}
#if 0
--
Charles Jardine - Computing Service, University of Cambridge
cj10@cam.ac.uk Tel: +44 1223 334506, Fax: +44 1223 334679
Re: Perl 5.7.3 breaks mod_perl tied handles [PATCH]
Posted by Stas Bekman <st...@stason.org>.
Charles Jardine wrote:
> I have been testing my mod_perl-1.26 applications under perl 5.7.3.
>
> I have discovered that the tying of STDIN and STDOUT does not work.
Great work, Charles!
the output of 'diff -u' is a preffered format for patches :)
[snip]
> This
> patch makes mod_perl work with 5.7.3, but, of course, stops it
> working with 5.6.x. It is beyond my knowledge to make this patch
> version dependent, as it needs to be.
here is the one that works for all 5.x versions. Tested with 5.7.3 and
5.6.1.
Index: src/modules/perl/perlio.c
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/perlio.c,v
retrieving revision 1.7
diff -u -r1.7 perlio.c
--- src/modules/perl/perlio.c 13 Jun 2001 21:27:51 -0000 1.7
+++ src/modules/perl/perlio.c 18 Mar 2002 15:48:39 -0000
@@ -51,12 +51,25 @@
#define dHANDLE(name) GV *handle = gv_fetchpv(name, TRUE, SVt_PVIO)
+#if (PERL_REVISION == 5 && PERL_VERSION < 7)
+
#define TIEHANDLE(name,obj) \
{ \
dHANDLE(name); \
sv_unmagic((SV*)handle, 'q'); \
sv_magic((SV*)handle, obj, 'q', Nullch, 0); \
}
+
+#else
+
+#define TIEHANDLE(name,obj) \
+{ \
+ dHANDLE(name); \
+ sv_unmagic((SV*)GvIOp((SV*)handle), 'q'); \
+ sv_magic((SV*)GvIOp((SV*)handle), obj, 'q', Nullch, 0); \
+}
+
+#endif
#if 0
#define TIED tied_handle
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/