Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: wrappers, unloading, and dependencies

Bart Schaefer wrote:

> On Dec 16, 11:39am, Sven Wischnowsky wrote:
> } Subject: PATCH: wrappers, unloading, and dependencies
> }
> } With the patch I send modules on which modules whose unloading is
> } currently delayed [depend] may be unloaded immediatly.  This means
> } that if the wrapper function uses data or functions of the module
> } depended upon may fail if the access appears after the execution of
> } the shell function and the lower level module was unloaded (and could
> } be unloaded immediately).
> As I said before, I think you're going to end up delaying unloading of
> all modules until all wrappers are finished.  Now that you've split the
> boot_/setup_ and cleanup_/finish_ parts, there's no reason to unload a
> module instantly, so why even try?
> Following the dependency chains around is much more complicated than
> necessary, I think.

Yes, using one static variable in module.c to count all wrappers and
unloading all modules with MOD_UNLOAD when it reaches zero would be
simpler, but only if we don't care about the order the finish
functions are called. If we want them to be called from depending to
base modules we would end up with a loop like the one we have now in

Alternatively we could keep a list of modules in the order their
unloading was requested, but then we would need the code to keep this
list up-to-date.

> } But of course that wouldn't be fully secure either, we would also have
> } to enforce that modules initialize/finalize all data other modules
> } might be interested in in the setup and finish functions, *not* in the
> } boot/cleanup functions. And that, of course, can't be guarenteed since
> } module writers are free to do what they want.
> } 
> } Making the implementation of setup/finish mandatory might help here
> } but doesn't ensure the right behavior either.
> There's no way to prevent people from writing buggy modules, period.  You
> tell them the rules and they get to fix the module if it does something
> bad.

Thanks, that's what I wanted to hear. (And I will send a cleanup patch 
for the module stuff today that will change the documentation.)

> } So we can either make find_module() be accessible from modules and add 
> } a comment in the documentation the this can be used in the wrapper to
> } test if the modules needed are still loaded or we use the patch below
> } to delay unloading of modules depended upon and to change the
> } documentation.
> If find_module() were accessible from modules, then a module could auto-
> load any others on which it depends; that'd be pretty nice.  But I would
> not require modules to test again when unloading, as that's something the
> shell should be able to make work.

Making it accessible is simple, maybe with a little wrapper so that we 
return the module itself (not the node).

> Now, should I apply this patch, or wait for some other one?

Refering to my comment above, I'd say yes.


Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx

Messages sorted by: Reverse Date, Date, Thread, Author