[Dovecot] Question about memory management in plugins

Peter Mogensen apm at one.com
Thu Aug 4 23:11:26 EEST 2011


Hi,

I've writing an passdb/userdb plugin (see my previous question about a 
plugin authenticating via a UNIX socket protocol).

Now... the protocol spoken over this socket is JSON-based and I'm using 
a SAX-like event based parser which maintains a parse context between 
callbacks.

Now... I'm a little bit in doubt about which dovecot memory management 
method would be best for data in this parser context.

Alloc-only pools seems wrong cause the parser object is used as long as 
the connection is open and there might run many auth requests over the 
connection before it's freed making the pool grow for long time.

Data stack allocation won't work either, since with all this async 
network and callbacks, there's really no where to place the stack frame.

So I end up using i_* and i_free for all data during the lifetime of the 
connection.

Is there a better way?

If I could only free my pool-allocated data, but I can't since it's 
almost never the last allocated data I want to free.

/Peter


More information about the dovecot mailing list