perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug MacEachern <do...@covalent.net>
Subject Re: [patch] PerlIO layer for APR
Date Fri, 07 Dec 2001 05:03:00 GMT
On Fri, 7 Dec 2001, Stas Bekman wrote:

cool!  one major problem with the file layout/linking however.
neither perlio nor apr is tied to httpd, so the APR PerlIO layer shouldn't
be either.  that is, it should be possible to use the APR PerlIO layer
outside of httpd.  there's no need to use the .map stuff for this.  you
can just create: 
xs/APR/PerlIO
with:
apr_perlio.h - was modperl_perlio.h
apr_perlio.c - was modperl_perlio.c
PerlIO.xs - just has the BOOT section to add the layer
PerlIO.pm - use APR () and load PerlIO.so
Makefile.PL - ModPerl::MM::WriteMakefile(
                  NAME => 'APR::PerlIO',
                  VERSION_FROM => 'PerlIO.pm',
                  OBJECT => 'PerlIO.o apr_perlio.o');

when PerlIO.pm does 'use APR ()' it is a noop inside modperl and
outside loads libapr, libaprutil and takes care of
apr_initialize/apr_terminate.

> - currently cannot pass $r|$s via open :( using modperl_global_get_pconf

we can't do that.  pconf can only be used at startup.
if builtin open doesn't support passing an APR::Pool reference, then we
need to have an APR::PerlIO::open that does.

another thing to consider is how to map apr_file_t's that are returned by
existing apache and apr functions.  won't be able to use the builtin open
for those.

functions themselves look good, just a few style comments...
 
> +IV
> +PerlIOAPR_popped(PerlIO *f)

all of these functions should be static.  and should also follow the
style where return type is on the same line as function name:
static IV PerlIOAPR_popped(...)


> +{
> +    dTHX;

would be nice if we could "fix" Perl so dTHX is not needed for any of
these functions.

> +    switch (*mode) {
> +        case 'a' : apr_flag = APR_APPEND | APR_CREATE; break;
> +        case 'w' : apr_flag = APR_WRITE  | APR_CREATE; break;
> +        case 'r' : apr_flag = APR_READ;                break;
> +        default  :
> +    }

should follow style of other switch statement in modperl.

> +IV
> +PerlIOAPR_close(PerlIO *f)
> +{
> +    PerlIOAPR *st = PerlIOSelf(f, PerlIOAPR);
> +    IV code = PerlIOBase_close(f);
> +        if ((apr_file_flush(st->file) != APR_SUCCESS)) {
> +            /* XXX: error? */
> +            return 0;
> +        }

indenting off.

> +    /* XXX: what's this for? */
> +    PerlIOBase(f)->flags &= ~(PERLIO_F_RDBUF|PERLIO_F_WRBUF);

turns off buffering flags, dunno if it actually needs to.

> +PerlIO_funcs PerlIO_APR = {

this should be static too.

also TestUtil::apr_io should be TestAPR::perlio.  and of course should be
skipped if perlio isn't available.







---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message