[collectd] [PATCH] perl plugin: Fixed error in ithread shutdown loop.

Sebastian Harl sh at tokkee.org
Tue Nov 20 09:15:37 CET 2007


Using the sfree() macro, the loop variable was accidentally set to NULL at the
end of the loop, causing the loop to terminate after the first iteration.

Signed-off-by: Sebastian Harl <sh at tokkee.org>
---

Sorry, I forgot to send in this patch - it has to be applied before "perl
plugin: Shut down an ithread if the embedding pthread terminates.".

---
 src/perl.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/perl.c b/src/perl.c
index cced76b..c109de9 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -936,9 +936,13 @@ static int perl_shutdown (void)
 	t = perl_threads->tail;
 
 	while (NULL != t) {
+		c_ithread_t *last = NULL;
+
 		aTHX = t->interp;
 		PERL_SET_CONTEXT (aTHX);
 
+		log_debug ("Shutting down Perl interpreter %p...", aTHX);
+
 #if COLLECT_DEBUG
 		sv_report_used ();
 #endif /* COLLECT_DEBUG */
@@ -946,9 +950,10 @@ static int perl_shutdown (void)
 		perl_destruct (aTHX);
 		perl_free (aTHX);
 
+		last = t;
 		t = t->prev;
 
-		sfree (t);
+		sfree (last);
 	}
 
 	pthread_mutex_unlock (&perl_threads->mutex);
-- 
1.5.3.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/20071120/86959d29/attachment.pgp 


More information about the collectd mailing list