X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fperl.c;h=1ad72487cc329c487eef65cc65837edee74bfc31;hb=c1406acc1770790a46fc674353154e46354afc9d;hp=3be3762132f1a528ed517a6180f9ef3550255d16;hpb=348fa70f34d7e32fafebb82053e0c84625c2ba67;p=collectd.git diff --git a/src/perl.c b/src/perl.c index 3be37621..1ad72487 100644 --- a/src/perl.c +++ b/src/perl.c @@ -25,7 +25,6 @@ */ #include "collectd.h" -#include "common.h" #include "configfile.h" @@ -41,6 +40,7 @@ /* ... while we want the definition found in plugin.h. */ #include "plugin.h" +#include "common.h" #define PLUGIN_INIT 0 #define PLUGIN_READ 1 @@ -959,6 +959,8 @@ static XS (boot_Collectd) static int perl_config (const char *key, const char *value) { + assert (NULL != perl); + log_debug ("perl_config: key = \"%s\", value=\"%s\"", key, value); if (0 == strcasecmp (key, "LoadPlugin")) { @@ -993,24 +995,32 @@ static int perl_config (const char *key, const char *value) static int perl_init (void) { + assert (NULL != perl); + PERL_SET_CONTEXT (perl); return pplugin_call_all (PLUGIN_INIT); } /* static int perl_init (void) */ static int perl_read (void) { + assert (NULL != perl); + PERL_SET_CONTEXT (perl); return pplugin_call_all (PLUGIN_READ); } /* static int perl_read (void) */ static int perl_write (const data_set_t *ds, const value_list_t *vl) { + assert (NULL != perl); + PERL_SET_CONTEXT (perl); return pplugin_call_all (PLUGIN_WRITE, ds, vl); } /* static int perl_write (const data_set_t *, const value_list_t *) */ static void perl_log (int level, const char *msg) { + assert (NULL != perl); + PERL_SET_CONTEXT (perl); pplugin_call_all (PLUGIN_LOG, level, msg); return; @@ -1021,6 +1031,14 @@ static int perl_shutdown (void) int i = 0; int ret = 0; + plugin_unregister_log ("perl"); + plugin_unregister_config ("perl"); + plugin_unregister_init ("perl"); + plugin_unregister_read ("perl"); + plugin_unregister_write ("perl"); + + assert (NULL != perl); + PERL_SET_CONTEXT (perl); ret = pplugin_call_all (PLUGIN_SHUTDOWN); @@ -1054,8 +1072,11 @@ static int perl_shutdown (void) perl_destruct (perl); perl_free (perl); + perl = NULL; PERL_SYS_TERM (); + + plugin_unregister_shutdown ("perl"); return ret; } /* static void perl_shutdown (void) */