Changes between Version 9 and Version 10 of ModParrotArchitecture

Show
Ignore:
Timestamp:
11/29/08 16:17:28 (6 years ago)
Author:
jhorwitz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ModParrotArchitecture

    v9 v10  
    1515 * PMC: Parrot Magic Cookie 
    1616 * Context: a data structure containing information about the current connection 
     17 * Interpreter: a Parrot interpreter ({{{Parrot_Interp}}}) 
    1718 
    1819== Design Goals == 
     
    5758The block of Apache data structures lists all possible structures that Apache may pass to a handler.  As a rule, if any of the Apache data structures are in scope, mod_parrot MUST update the corresponding pointer in the context before calling a metahandler.  This ensures that metahandlers can access the proper data structures, as they are given only the context to work with. 
    5859 
    59 To maintain state, the same context must be used for all phases of a request, as it contains a reference to the interpreter. 
    60  
    6160=== Context Pools === 
    6261 
    63 Contexts are allocated from context pools, which are populated at startup and tuned dynamically at runtime.  Contexts contain pointers to Parrot interpreters so this also provides mod_parrot with a pool of interpreters. 
     62Contexts are allocated from context pools, which are populated at startup and tuned dynamically at runtime.  There is a single global pool, plus one pool per virtual host configured with {{{+Parent}}}. Virtual hosts without {{{+Parent}}} share the global pool.  Contexts contain pointers to Parrot interpreters so this also provides mod_parrot with a pool of interpreters.  Contexts are aware of their slot in the pool array (see {{{pool_index}}}). 
    6463 
    65 ==== Interpreter Lifecycle ==== 
     64=== Context Lifecycle === 
     65 
     66Contexts are created at Apache startup during the configuration phase, when interpreters are needed to register various HLL modules and parse directives.  An interpreter is always started when a context is created. 
     67 
     68 
     69To maintain state, the same context must be used for all phases of a request, as it contains a reference to the interpreter.  When a context is needed, code should call {{{init_ctx(server_rec *s, conn_rec *c)}}}, which will return an available context from the pool.  If {{{conn_rec *c}}} is non-null, {{{init_ctx}}} will return the context bound to that connection, or bind an available connection and return it.  Code in hooks that run before the pre-connection phase should pass a NULL connection. 
     70 
     71When a context is in use, it is locked behind the scenes by {{{reserve_ctx}}}.  While code should not call this function directly, it MUST call {{{release_ctx}}} after each phase is complete to unlock the context.  This may change in the future, as connection binding requires the use of the same context, so all this locking and unlocking is just overhead. 
     72 
     73When the request/connection is complete, it is unlocked and disassociated from the connection by {{{modparrot_conn_cleanup}}}, a connection-scope pool cleanup handler.  
    6674 
    6775== Apache Interface ==