[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Overlays : Cache - Entry - AttributeDescription

Hallvard B Furuseth <h.b.furuseth@usit.uio.no> wrote:
Yes, the backend/overlay which returns an entry often owns that entry.
If you are result and modifying rs->sr_entry, rs->sr_flags describe
ownership of the entry and if it is modifiable.  You can call

       rs_entry2modifiable( op, rs, on /*the overlay*/ );

to ensure rs->sr_entry is modifiable.  If necessary, this duplicates
the entry and frees/releases the old one.  This invalidates any pointers
to/into the old sr_entry.  Note how e.g. overlays/valsort.c re-reads
rs->sr_entry->e_attrs if the entry was replaced.

At other times you may prefer to duplicate an entry "by hand"
with entry_dup() to get a modifiable copy, and free it later with
entry_free() or by setting the MUSTBEFREED flag in rs->sr_flags.

If your overlay needs to free the entry in a special way, it can
set a entry release function and set the MUSTRELEASE flag to alert
other code that the entry can't just be entry_free()d.

Hey Hallvard!
Thanks a lot for your answers, they were very help full!

To be sure, when I use entry_dub(); it makes a duplication of the entry from the server cache to somewhere in the memory.
So I just need to make the pointer of the SlapReply point to my new duplicated entry,modified it as wanted,and free it once the response have been send to the client.
If, I'm multi-threading and an other request arrives it will use the entry still in the cache and not my modified duplication, is that write?

Johan Jakus