The image verification code you entered is incorrect.

HLL configuration directives live!

mod_parrot now has support for HLL configuration directives! They're still a bit tedious to configure since everything is in PIR and I'm missing a few Apache constants, but it works! I committed a proof-of-concept directive for mod_perl6 called, well, what else, Perl6ResponseHandler. So this works now:

<Location /foo>
    SetHandler perl6-code
    Perl6ResponseHandler Foo::Bar
</Location>

The only caveat is that you have to use ParrotLoadImmediate to load the perl6 HLL layer, since ParrotLoad doesn't start the interpreter until after the configuration phase. mod_perl has a similar setup with PerlLoadModule. Eventually the loading of HLL layers will be automatic, or at least in their own config file so you don't have to worry about it.

Now for the interesting bits. As I noted in my previous post, I got a proof-of-concept working where I was able to create and load a module at runtime, complete with custom directives; I just needed to refactor it for mod_parrot. It actually wasn't that bad, except for one minor thing. Unlike modules written in an HLL which implement their own directives and modify their own configs, the directives implementing the HLL itself need to modify mod_parrot's configuration. In other words, one module needs to modify another's configuration! This was painful to implement, especially for the directory configuration, but I did it in about 2 days without doing anything shady, and it works.

Here's what Perl6ResponseHandler looks like in the perl6 HLL layer:

.sub __onload :anon :load

    # [skip perl6 initialization code]
 
    # register apache directives
    .local pmc add_module, cmds

    load_bytecode 'Apache/Module.pbc'

    cmds = new 'Array'
    cmds = 1
    $P0 = new 'Hash'

    $P1 = new 'String'
    $P1 = 'Perl6ResponseHandler'
    $P0['name'] = $P1
    $P1 = new 'Integer'
    $P1 = 1 # TAKE1
    $P0['args_how'] = $P1
    $P1 = get_hll_global 'cmd_perl6responsehandler'
    $P0['func'] = $P1
    $P1 = new 'Integer'
    $P1 = 8 # OR_AUTHCFG
    $P0['req_override'] = $P1
    $P1 = new 'String'
    $P1 = "usage: Perl6ResponseHandler handler-name"
    $P0['errmsg'] = $P1
    cmds[0] = $P0

    add_module = get_hll_global [ 'Apache'; 'Module' ], 'add'
    $P1 = add_module("modparrot_perl6_module", cmds)
.end

.sub cmd_perl6responsehandler
    .param pmc args
    .local string handler
    handler = args[0]
    $P0 = get_hll_global ['Apache'; 'Module'], 'modparrot_dircfg_handler'
    $P1 = $P0('perl6', handler)
.end

Of course it will be a bit prettier in the future when I work out the Apache constants and get this working in Perl 6 instead of PIR, but you get the picture. With this major milestone out of the way I can focus on exposing more of the Apache internals and really start kickin' the tires!

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.