Re: $r->document_root

[prev] [thread] [next] [Date index for 2005/02/19]

From: Joe Schaefer
Subject: Re: $r->document_root
Date: 14:12 on 19 Feb 2005
Stas Bekman <stas@xxxxxx.xxx> writes:


[...]

> I was just adding a note to the API method doc saying:
>
>    it's important to mention that at the end of each request where
>    you modify this setting you absolutely must restore it to its
>    original value.
>
> but it doesn't work, since the resetting will be allocated from the request
> pool, which will go away at the end of the request, leaving the data
> corrupted. 
>
> So unless I miss something we have two options:
>
> 1) nuke that method completely
>
> 2) either provide a new method that restores the data using a preallocated
> string from the server pool or do that internally in the server

Why not add a request pool cleanup that just restores the original pointer?

    struct docroot_info {
        const char **docroot;
        const char *original;
    };

    static apr_status_t restore_docroot(void *data)
    {
        struct docroot_info * di = data;
        *di->docroot  = original;
        return APR_SUCCESS;
    }


Then in the original XS...

       struct docroot_info *di;
       ...
       di = apr_palloc(r->pool, sizeof *di);
       di->docroot = &conf->ap_document_root;
       di->original = conf->ap_document_root;
       apr_pool_cleanup_register(p, di, restore_docroot, restore_docroot);

       conf->ap_document_root = apr_pstrdup(r->pool, SvPV_nolen(new_root));


        -- 
        Joe Schaefer

(message missing)

$r->document_root
Cahill, Earl 23:14 on 14 Feb 2005

Re: $r->document_root
Geoffrey Young 23:21 on 14 Feb 2005

Re: $r->document_root
Geoffrey Young 23:26 on 14 Feb 2005

RE: $r->document_root
Cahill, Earl 20:43 on 15 Feb 2005

Re: $r->document_root
Geoffrey Young 21:10 on 15 Feb 2005

Re: $r->document_root
Stas Bekman 01:48 on 19 Feb 2005

Re: $r->document_root
Stas Bekman 02:02 on 19 Feb 2005

Re: $r->document_root
Geoffrey Young 13:54 on 19 Feb 2005

Re: $r->document_root
Stas Bekman 17:21 on 19 Feb 2005

Re: $r->document_root
Joe Schaefer 14:12 on 19 Feb 2005

Re: $r->document_root
Geoffrey Young 05:26 on 20 Feb 2005

Re: $r->document_root
Stas Bekman 01:29 on 21 Feb 2005

Re: $r->document_root
Joe Schaefer 02:38 on 21 Feb 2005

Re: $r->document_root
Stas Bekman 02:43 on 21 Feb 2005

Generated at 12:48 on 22 Feb 2005 by mariachi v0.52