Hi,
We have a slapd preoperation + extendedop plugin that largely works well
for us. We have recently discovered that it leaks a small amount of
memory, which, over time, creates a headache.
I would appreciate advice on the proper way to solve this problem. In
short, our code allocates a small bit of state information for each
connection. We register a callback with SLAPI_PLUGIN_PRE_UNBIND_FN
which cleans up that state information.
However, that function is only invoked for authenticated connections;
simple anonymous binds never invoke the unbind callback, and hence the
leak. That is, our problem seems to be when the bind is both simple
(LDAP_AUTH_NONE) and anonymous (null DN).
If we set bindSubtree to '*' (ALL_DATA), then our unbind function is
invoked for the anonymous connections. It is not clear to us what the
ramifications are of that setting, and what effect making that change
will have on our plugin. Advice would greatly appreciated.
Alternately, inspection of factory.c suggests that
slapi_register_object_extension() could be used as a way for creating
and destroying the connection specific information we need to track.
However, those callbacks appear to be intended only for slapd internal
server plugins, not for external plugins. In order to make that work,
we would need a way of connecting a Slapi_PBlock to the opaque
Connection structure that is passed to the constructor and destructor. I
imagine that we could achieve that by modifying the slapi library to
expose something like slapi_get_conn_id() which would take the opaque
Connection * pointer and return the connection id. My concern is that
needing that call is a signal that it's The Wrong Approach (TM).
If it helps, some bits of how we construct our plugin are shared here:
https://gist.github.com/jwhite66/128aea1b186eaed4c58accfe30590d5f
Clue bats welcome; any advice is appreciated.
Cheers,
Jeremy