I have a C library that I wrapped as gsubrs that get put into a Guile module. The C library wants a library_init() function called when it is initialized and a library_end() function called when it taken down.
(for the curious, it is specifically mysql_library_init() and mysql_library_end().) The library_init() call is easy because it can be called automatically in the initialization function called by (load-extension "libfoo.so" "foo_init"). Since libraries are never unloaded, I guess I can wait until the program exit to call library_end(). I read this thread http://thread.gmane.org/gmane.lisp.guile.user/6430/focus=6443 This suggests dynamic-wind is the way to go, but, I don't think it would work in my case because I want to keep this in a Guile wrapper module that gets loaded with use-module. I've got one crazy idea. I could create a new special SMOB type which calls library_end() as part of the SMOB's free function. When the Guile library is loaded, it will define a single variable of that type in the module's environment. But then I started think about what happens if the module is used in multiple threads, and it made my head hurt. Any better ideas? -Mike Gran
