[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gluster-devel] Can function arguments be modified ?
From: |
Jeff Darcy |
Subject: |
Re: [Gluster-devel] Can function arguments be modified ? |
Date: |
Sun, 11 Mar 2012 10:19:32 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 |
On 03/10/2012 03:34 PM, Anand Avati wrote:
> There is a no rule written on stone here. It is good practice to make
> copies. Note that for things like iatt structure, you need not
> "allocate" and "free" from the heap. Most of the time you can copy to
> a structure on the stack, modify and return that. You will see that
> for parameters which get modified in the callback (typically
> aggregated from multiple subvolumes), most translators have a
> "modified" copy inside frame->local.
Object-lifecycle management in GlusterFS can be a bit tricky. The two most
common patterns I see are that dict_t and similar structures will be
*dereferenced* either when the originator's (i.e. FUSE or protocol/server)
STACK_WIND returns or when the callback completes. Thus, you can usually
ensure their continued existence by doing a dict_ref (or data_ref if you really
only care about a single value). IIRC, DHT already does this for some layout
xattrs that it aggregates across subvolumes. In most cases, though, Avati is
correct: good practice would be to make a copy.