From: Sebastian Harl Date: Thu, 29 May 2008 22:09:18 +0000 (+0200) Subject: perl plugin: Don't abort if initializing the interpreter failed. X-Git-Tag: collectd-4.4.1~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d71f8c2dfb67859cdadcf066a79460768377aa68;p=collectd.git perl plugin: Don't abort if initializing the interpreter failed. 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 Signed-off-by: Florian Forster --- diff --git a/src/perl.c b/src/perl.c index bd6345ba..9bd3b4d2 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);