[collectd] [PATCH] plugin.c: Advance the llentry_t pointer before calling the shutdown callback.

Sebastian Harl sh at tokkee.org
Sun May 20 22:59:21 CEST 2007


> Important note: Unregistering the shutdown callback during shutdown is
> somewhat tricky. Doing that frees the llist_t entry in plugin.c:list_shutdown.
> This might cause a segfault in plugin_shutdown_all () when it tries to access
> the next pointer of that entry. If plugin_unregister_shutdown () is the last
> statement before the return from the shutdown callback this should be save in
> about 99% of all cases. Still there should be some better way to handle this.

This is an imho nice way to fix it.

Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
 src/plugin.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/plugin.c b/src/plugin.c
index 64dbf78..3eaf3af 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -607,9 +607,9 @@ void plugin_shutdown_all (void)
 	while (le != NULL)
 	{
 		callback = (int (*) (void)) le->value;
-		(*callback) ();
-
 		le = le->next;
+
+		(*callback) ();
 	}
 } /* void plugin_shutdown_all */
 
-- 
1.4.4.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20070520/bd7fd6f9/attachment.pgp 


More information about the collectd mailing list