[collectd] [PATCH] perl plugin: Re-get the perl interpreter after parsing each configuration option.

Sebastian Harl sh at tokkee.org
Tue Aug 26 11:52:53 CEST 2008


The current perl interpreter might change while parsing the configuration
(e.g. the first interpreter is created by the "LoadPlugin" option), so this is
to make sure that we're using the right interpreter at all times.

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

diff --git a/src/perl.c b/src/perl.c
index 8106360..d34eff4 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -1650,16 +1650,14 @@ static int perl_config (oconfig_item_t *ci)
 {
 	int i = 0;
 
-	dTHX;
-
-	/* dTHX does not get any valid values in case Perl
-	 * has not been initialized */
-	if (NULL == perl_threads)
-		aTHX = NULL;
+	dTHXa (NULL);
 
 	for (i = 0; i < ci->children_num; ++i) {
 		oconfig_item_t *c = ci->children + i;
 
+		if (NULL != perl_threads)
+			aTHX = PERL_GET_CONTEXT;
+
 		if (0 == strcasecmp (c->key, "LoadPlugin"))
 			perl_config_loadplugin (aTHX_ c);
 		else if (0 == strcasecmp (c->key, "BaseName"))
-- 
1.6.0.90.g436ed

-------------- 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/20080826/e582aed2/attachment.pgp 


More information about the collectd mailing list