Re: Q - Apache::Request-new(undef) works?

2001-12-12 Thread Joe Schaefer

darren chamberlain [EMAIL PROTECTED] writes:

 Jay Lawrence [EMAIL PROTECTED] said something to this effect on
 12/11/2001:  
  In my development I neglected to supply the Apache request
  object when I called Apache::Request-new( $r ). Actually $r
  was undef. It still works! I am just wondering if this is
  expected behaviour and if it will be supported going forward or
  was this just a fluke?
 
 The Apache instance that gets passed to Apache::Request::new
 apepars to not be required:
 
 # From libapreq-0.33/Request/Request.xs:
 165 static ApacheRequest *sv_2apreq(SV *sv)
^

Unfortunately this isn't the relevant function here- the typemap for 
Apache objects is governed by sv2request_rec, which is part of
mod_perl's perl_util.c file.

-- 
Joe Schaefer




Q - Apache::Request-new(undef) works?

2001-12-11 Thread Jay Lawrence



Howdy!

In my development I neglected to supply the Apache 
request object when I called Apache::Request-new( $r ). Actually $r was 
undef. It still works! I am just wondering if this is expected behaviour and if 
it will be supported going forward or was this just a 
fluke?Thanks,
J


Re: Q - Apache::Request-new(undef) works?

2001-12-11 Thread Joe Schaefer

Jay Lawrence [EMAIL PROTECTED] writes:

 In my development I neglected to supply the Apache request object when
 I called Apache::Request-new( $r ). Actually $r was undef. It still
 works! I am just wondering if this is expected behaviour and if it
 will be supported going forward or was this just a fluke?

I'd say it's a fluke- $r needs to be attached somehow to the actual
request object; otherwise I think you're introducing a memory leak 
and/or possibly a segfault.  Unless Doug says otherwise, I wouldn't 
rely on this behavior for an undef'd arg to Apache::Request::new.

-- 
Joe Schaefer




Re: Q - Apache::Request-new(undef) works?

2001-12-11 Thread darren chamberlain

Jay Lawrence [EMAIL PROTECTED] said something to this effect on 12/11/2001:
 In my development I neglected to supply the Apache request
 object when I called Apache::Request-new( $r ). Actually $r
 was undef. It still works! I am just wondering if this is
 expected behaviour and if it will be supported going forward or
 was this just a fluke?

The Apache instance that gets passed to Apache::Request::new
apepars to not be required:

# From libapreq-0.33/Request/Request.xs:
165 static ApacheRequest *sv_2apreq(SV *sv)
166 {
167 if (SvROK(sv)  sv_derived_from(sv, Apache::Request)) {
168 SV *obj = sv;
169 
*snip*
179 return (ApacheRequest *)SvIV((SV*)SvRV(obj));
180 }
181 else {
182 return ApacheRequest_new(perl_request_rec(NULL));
183 }
184 }

perl_request_rec is defined in mod_perl/src/modules/perl/mod_perl.c
(from the mod_perl distribution); it sets the static IV
mp_request_rec to a request_rec:

# mod_perl/src/modules/perl/mod_perl.c:
 66 static IV mp_request_rec;
   1685 request_rec *perl_request_rec(request_rec *r)
   1686 {
   1687 if(r != NULL) {
   1688 mp_request_rec = (IV)r;
   1689 return NULL;
   1690 }
   1691 else
   1692 return (request_rec *)mp_request_rec;
   1693 }

So, at least with the current versions of mod_perl (1.26) and
libapreq (0.33), not passing Apache-request to
Apache::Request::new seems safe.

(darren)

-- 
Democracy is a form of government that substitutes election by the
incompetent many for appointment by the corrupt few.
-- George Bernard Shaw