You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by st...@apache.org on 2003/10/15 02:40:56 UTC
cvs commit: modperl-2.0/src/modules/perl modperl_io_apache.c
stas 2003/10/14 17:40:56
Modified: src/modules/perl modperl_io_apache.c
Log:
add protection against possible uses of stale filehandles, and some extra
tracing for open/close
Revision Changes Path
1.5 +18 -6 modperl-2.0/src/modules/perl/modperl_io_apache.c
Index: modperl_io_apache.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_io_apache.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -u -r1.4 -r1.5
--- modperl_io_apache.c 4 Sep 2003 03:31:50 -0000 1.4
+++ modperl_io_apache.c 15 Oct 2003 00:40:56 -0000 1.5
@@ -44,6 +44,7 @@
if (arg) {
st->r = modperl_sv2request_rec(aTHX_ arg);
+ MP_TRACE_o(MP_FUNC, "stored request_rec obj: 0x%lx", st->r);
}
else {
Perl_croak(aTHX_ "$r wasn't passed");
@@ -54,8 +55,6 @@
* 'mode' */
code = PerlIOBase_pushed(aTHX_ f, mode, Nullsv, tab);
- MP_TRACE_o(MP_FUNC, "done");
-
return code;
}
@@ -142,13 +141,20 @@
PerlIOApache_flush(pTHX_ PerlIO *f)
{
PerlIOApache *st = PerlIOSelf(f, PerlIOApache);
- modperl_config_req_t *rcfg = modperl_config_req_get(st->r);
+ modperl_config_req_t *rcfg;
+
+ if (!st->r) {
+ Perl_warn(aTHX_ "an attempt to flush a stale IO handle");
+ return -1;
+ }
/* no flush on readonly io handle */
if (! (PerlIOBase(f)->flags & PERLIO_F_CANWRITE) ) {
return -1;
}
+ rcfg = modperl_config_req_get(st->r);
+
MP_CHECK_WBUCKET_INIT("flush");
MP_TRACE_o(MP_FUNC, "%d bytes [%s]", rcfg->wbucket->outcnt,
@@ -169,9 +175,15 @@
static IV
PerlIOApache_close(pTHX_ PerlIO *f)
{
- /* XXX: just temp for tracing */
- MP_TRACE_o(MP_FUNC, "done");
- return PerlIOBase_close(aTHX_ f);
+ IV code = PerlIOBase_close(aTHX_ f);
+ PerlIOApache *st = PerlIOSelf(f, PerlIOApache);
+
+ MP_TRACE_o(MP_FUNC, "done with request_rec obj: 0x%lx", st->r);
+ /* prevent possible bugs where a stale r will be attempted to be
+ * reused (e.g. dupped filehandle) */
+ st->r = NULL;
+
+ return code;
}
static IV