[collectd] [PATCH] perl plugin: Don't abort if initializing the interpreter failed.

Sebastian Harl sh at tokkee.org
Fri May 30 00:09:18 CEST 2008


There is no reason to shutdown collectd completely just because of some
Perl specific error. An error message is logged in this case, so the user
has means to detect it.

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

diff --git a/src/perl.c b/src/perl.c
index bd6345b..9bd3b4d 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -1441,7 +1441,7 @@ static int init_pi (int argc, char **argv)
 		log_err ("init_pi: pthread_key_create failed");
 
 		/* this must not happen - cowardly giving up if it does */
-		exit (1);
+		return -1;
 	}
 
 #ifdef __FreeBSD__
@@ -1476,7 +1476,13 @@ static int init_pi (int argc, char **argv)
 
 	if (0 != perl_parse (aTHX_ xs_init, argc, argv, NULL)) {
 		log_err ("init_pi: Unable to bootstrap Collectd.");
-		exit (1);
+
+		perl_destruct (perl_threads->head->interp);
+		perl_free (perl_threads->head->interp);
+		sfree (perl_threads);
+
+		pthread_key_delete (perl_thr_key);
+		return -1;
 	}
 
 	/* Set $0 to "collectd" because perl_parse() has to set it to "-e". */
@@ -1518,7 +1524,9 @@ static int perl_config_loadplugin (pTHX_ oconfig_item_t *ci)
 		return (1);
 	}
 
-	init_pi (perl_argc, perl_argv);
+	if (0 != init_pi (perl_argc, perl_argv))
+		return -1;
+
 	assert (NULL != perl_threads);
 	assert (NULL != perl_threads->head);
 
-- 
1.5.5.1.316.g377d9

-------------- 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/20080530/292b7468/attachment.pgp 


More information about the collectd mailing list