/* do not automatically get the thread specific perl interpreter */
#define PERL_NO_GET_CONTEXT
+#define DONT_POISON_SPRINTF_YET 1
#include "collectd.h"
+#undef DONT_POISON_SPRINTF_YET
#include "configfile.h"
#include <EXTERN.h>
#include <perl.h>
+#if __GNUC__
+# pragma GCC poison sprintf
+#endif
+
#include <XSUB.h>
/* Some versions of Perl define their own version of DEBUG... :-/ */
list.host[DATA_MAX_NAME_LEN - 1] = '\0';
}
else {
- strcpy (list.host, hostname_g);
+ sstrncpy (list.host, hostname_g, sizeof (list.host));
}
if (NULL != (tmp = hv_fetch (values, "plugin", 6, 0))) {
aTHX = t->interp;
- if (NULL != base) {
+ if ((NULL != base) && (NULL != PL_endav)) {
av_clear (PL_endav);
av_undef (PL_endav);
PL_endav = Nullav;
log_err ("init_pi: pthread_key_create failed");
/* this must not happen - cowardly giving up if it does */
- exit (1);
+ return -1;
}
#ifdef __FreeBSD__
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". */
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);