Skip to content

Commit

Permalink
Add qof_finalize_backend_libraries() which is called during shutdown.…
Browse files Browse the repository at this point in the history
… This routine checks each backend

library for an exported qof_backend_module_finalize() routine, and if it exists, calls it so that the
backend can free any resources which have been allocated.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18485 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
Phil Longstaff committed Dec 11, 2009
1 parent 16144d6 commit a3b87ec
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/libqof/qof/qofbackend.c
Expand Up @@ -502,6 +502,8 @@ qof_backend_commit_exists(const QofBackend *be)
}
}

static GSList* backend_module_list = NULL;

gboolean
qof_load_backend_library (const char *directory, const char* module_name)
{
Expand All @@ -523,7 +525,25 @@ qof_load_backend_library (const char *directory, const char* module_name)
module_init_func();

g_module_make_resident(backend);
backend_module_list = g_slist_prepend( backend_module_list, backend );
return TRUE;
}

void
qof_finalize_backend_libraries(void)
{
GSList* node;
GModule* backend;
void (*module_finalize_func) (void);

for (node = backend_module_list; node != NULL; node = node->next) {
backend = (GModule*)node->data;

if (g_module_symbol(backend, "qof_backend_module_finalize",
(gpointer)&module_finalize_func))
module_finalize_func();

}
}

/************************* END OF FILE ********************************/
3 changes: 3 additions & 0 deletions src/libqof/qof/qofbackend.h
Expand Up @@ -269,6 +269,9 @@ KvpFrame* qof_backend_get_config(QofBackend *be);
gboolean
qof_load_backend_library(const gchar *directory, const gchar* module_name);

/** \brief Finalize all loaded backend sharable libraries. */
void qof_finalize_backend_libraries(void);

/** \brief Retrieve the backend used by this book */
QofBackend* qof_book_get_backend (const QofBook *book);

Expand Down
1 change: 1 addition & 0 deletions src/libqof/qof/qofutil.c
Expand Up @@ -523,6 +523,7 @@ qof_close(void)
qof_query_shutdown ();
qof_object_shutdown ();
guid_shutdown ();
qof_finalize_backend_libraries();
qof_util_string_cache_destroy ();
qof_log_shutdown();
}
Expand Down

0 comments on commit a3b87ec

Please sign in to comment.