projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rrdtool plugin: Sort the list of user defined `RRATimespan's.
[collectd.git]
/
src
/
perl.c
diff --git
a/src/perl.c
b/src/perl.c
index
c997749
..
f2cb7b6
100644
(file)
--- a/
src/perl.c
+++ b/
src/perl.c
@@
-25,8
+25,6
@@
*/
#include "collectd.h"
*/
#include "collectd.h"
-#include "common.h"
-#include "plugin.h"
#include "configfile.h"
#include "configfile.h"
@@
-35,6
+33,15
@@
#include <XSUB.h>
#include <XSUB.h>
+/* Some versions of Perl define their own version of DEBUG... :-/ */
+#ifdef DEBUG
+# undef DEBUG
+#endif /* DEBUG */
+
+/* ... while we want the definition found in plugin.h. */
+#include "plugin.h"
+#include "common.h"
+
#define PLUGIN_INIT 0
#define PLUGIN_READ 1
#define PLUGIN_WRITE 2
#define PLUGIN_INIT 0
#define PLUGIN_READ 1
#define PLUGIN_WRITE 2
@@
-326,7
+333,7
@@
static char *get_module_name (char *buf, size_t buf_len, const char *module) {
status = snprintf (buf, buf_len, "%s::%s", base_name, module);
if ((status < 0) || (status >= buf_len))
return (NULL);
status = snprintf (buf, buf_len, "%s::%s", base_name, module);
if ((status < 0) || (status >= buf_len))
return (NULL);
- buf[buf_len] = '\0';
+ buf[buf_len
- 1
] = '\0';
return (buf);
} /* char *get_module_name */
return (buf);
} /* char *get_module_name */
@@
-952,6
+959,8
@@
static XS (boot_Collectd)
static int perl_config (const char *key, const char *value)
{
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")) {
log_debug ("perl_config: key = \"%s\", value=\"%s\"", key, value);
if (0 == strcasecmp (key, "LoadPlugin")) {
@@
-986,24
+995,32
@@
static int perl_config (const char *key, const char *value)
static int perl_init (void)
{
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)
{
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)
{
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)
{
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;
PERL_SET_CONTEXT (perl);
pplugin_call_all (PLUGIN_LOG, level, msg);
return;
@@
-1014,6
+1031,14
@@
static int perl_shutdown (void)
int i = 0;
int ret = 0;
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);
PERL_SET_CONTEXT (perl);
ret = pplugin_call_all (PLUGIN_SHUTDOWN);
@@
-1047,8
+1072,11
@@
static int perl_shutdown (void)
perl_destruct (perl);
perl_free (perl);
perl_destruct (perl);
perl_free (perl);
+ perl = NULL;
PERL_SYS_TERM ();
PERL_SYS_TERM ();
+
+ plugin_unregister_shutdown ("perl");
return ret;
} /* static void perl_shutdown (void) */
return ret;
} /* static void perl_shutdown (void) */
@@
-1069,7
+1097,7
@@
static void xs_init (pTHX)
/*
* Create the perl interpreter and register it with collectd.
*/
/*
* Create the perl interpreter and register it with collectd.
*/
-void module_register (
modreg_e loa
d)
+void module_register (
voi
d)
{
char *embed_argv[] = { "", "-e", "bootstrap Collectd \""VERSION"\"", NULL };
int embed_argc = 3;
{
char *embed_argv[] = { "", "-e", "bootstrap Collectd \""VERSION"\"", NULL };
int embed_argc = 3;
@@
-1103,8
+1131,7
@@
void module_register (modreg_e load)
plugin_register_config ("perl", perl_config, config_keys, config_keys_num);
plugin_register_init ("perl", perl_init);
plugin_register_config ("perl", perl_config, config_keys, config_keys_num);
plugin_register_init ("perl", perl_init);
- if (load & MR_READ)
- plugin_register_read ("perl", perl_read);
+ plugin_register_read ("perl", perl_read);
plugin_register_write ("perl", perl_write);
plugin_register_shutdown ("perl", perl_shutdown);
plugin_register_write ("perl", perl_write);
plugin_register_shutdown ("perl", perl_shutdown);