Module system: last call for objections
Bill Gribble
grib@billgribble.com
Thu, 2 Aug 2001 10:13:49 -0500
On Thu, Aug 02, 2001 at 10:59:00AM -0400, Derek Atkins wrote:
> Good question. Part of me feels that the ref-count should be
> post-{load,unload} in all cases, but I'm not sure about that. Another
> part of me things it should be pre-load and post-unload, but that can
> get confusing, too.
If you call load(), immediately followed by unload(), my instinct is
that the handlers should get the same refcount. i.e. if you're
testing for the first load and the last unload, you shouldn't have to
be comparing against different values in the handlers.
Then the big question is "do you want refcount to be 1 or 0 on the
first call?". I tend to want it to be 0. That means the refcount is
pre-increment on the init() handler, post-decrement on the end()
handler, and the "special value" you have to test for in both is 0.
> Question: is it possible for the 'end()' function to fail?
well, gnc_module_unload can fail (if you pass it a bogus module arg,
for example) so there's room for passing information that the end
handler has failed. It probably makes sense for the end handler to
return an int too, just so the upper levels can have some way of
knowing that something failed in the unload process. However, if you
call unload() on a valid module with 0 refcount, it *will* be
dlclose()d no matter what the end handler returns... too uncertain to
leave it hanging around half-unloaded.
Thanks for your feedback!
b.g.