summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 04b3953)
raw | patch | inline | side by side (parent: 04b3953)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 22 Feb 2009 20:48:05 +0000 (21:48 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 22 Feb 2009 20:48:05 +0000 (21:48 +0100) |
src/network.c | patch | blob | history | |
src/perl.c | patch | blob | history | |
src/plugin.c | patch | blob | history | |
src/plugin.h | patch | blob | history | |
src/rrdtool.c | patch | blob | history |
diff --git a/src/network.c b/src/network.c
index 3b2c25b10aac86491be6605a622cdcf5323e3ab2..0434b35908ed578d7a5c7607a4ef104b4eb98999 100644 (file)
--- a/src/network.c
+++ b/src/network.c
* there, good. If not, well, then there is nothing to flush.. -octo
*/
static int network_flush (int timeout,
- const char __attribute__((unused)) *identifier)
+ const char __attribute__((unused)) *identifier,
+ user_data_t __attribute__((unused)) *user_data)
{
pthread_mutex_lock (&send_buffer_lock);
plugin_register_config ("network", network_config,
config_keys, config_keys_num);
plugin_register_init ("network", network_init);
- plugin_register_flush ("network", network_flush);
+ plugin_register_flush ("network", network_flush,
+ /* user_data = */ NULL);
} /* void module_register */
diff --git a/src/perl.c b/src/perl.c
index 00912668b019445aa3803e98da317178f681bc44..b600ca1d5e4a740ad85153dae85ebfe981b4ad5d 100644 (file)
--- a/src/perl.c
+++ b/src/perl.c
return pplugin_call_all (aTHX_ PLUGIN_NOTIF, notif);
} /* static int perl_notify (const notification_t *) */
-static int perl_flush (int timeout, const char *identifier)
+static int perl_flush (int timeout, const char *identifier,
+ user_data_t __attribute__((unused)) *user_data)
{
dTHX;
plugin_register_read ("perl", perl_read);
plugin_register_write ("perl", perl_write, /* user_data = */ NULL);
- plugin_register_flush ("perl", perl_flush);
+ plugin_register_flush ("perl", perl_flush, /* user_data = */ NULL);
plugin_register_shutdown ("perl", perl_shutdown);
return 0;
} /* static int init_pi (const char **, const int) */
diff --git a/src/plugin.c b/src/plugin.c
index bba8e54ffb6d2ff5bb1244b8eaf53ed3f2473bf5..49793dca7a29b65801dc47f4cfd1201190f87c2b 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
};
typedef struct write_func_s write_func_t;
+struct flush_func_s
+{
+ plugin_flush_cb callback;
+ user_data_t udata;
+};
+typedef struct flush_func_s flush_func_t;
+
/*
* Private variables
*/
int plugin_register_write (const char *name,
plugin_write_cb callback, user_data_t *user_data)
{
- write_func_t *wr;
+ write_func_t *wf;
- wr = (write_func_t *) malloc (sizeof (*wr));
- if (wr == NULL)
+ wf = (write_func_t *) malloc (sizeof (*wf));
+ if (wf == NULL)
{
ERROR ("plugin_register_write: malloc failed.");
return (-1);
}
- memset (wr, 0, sizeof (*wr));
+ memset (wf, 0, sizeof (*wf));
- wr->callback = callback;
+ wf->callback = callback;
if (user_data == NULL)
{
- wr->udata.data = NULL;
- wr->udata.free_func = NULL;
+ wf->udata.data = NULL;
+ wf->udata.free_func = NULL;
}
else
{
- wr->udata = *user_data;
+ wf->udata = *user_data;
}
- return (register_callback (&list_write, name, (void *) wr));
+ return (register_callback (&list_write, name, (void *) wf));
} /* int plugin_register_write */
int plugin_register_flush (const char *name,
- int (*callback) (const int timeout, const char *identifier))
+ plugin_flush_cb callback, user_data_t *user_data)
{
- return (register_callback (&list_flush, name, (void *) callback));
+ flush_func_t *ff;
+
+ ff = (flush_func_t *) malloc (sizeof (*ff));
+ if (ff == NULL)
+ {
+ ERROR ("plugin_register_flush: malloc failed.");
+ return (-1);
+ }
+ memset (ff, 0, sizeof (*ff));
+
+ ff->callback = callback;
+ if (user_data == NULL)
+ {
+ ff->udata.data = NULL;
+ ff->udata.free_func = NULL;
+ }
+ else
+ {
+ ff->udata = *user_data;
+ }
+
+ return (register_callback (&list_flush, name, (void *) ff));
} /* int plugin_register_flush */
int plugin_register_shutdown (char *name,
int plugin_unregister_flush (const char *name)
{
- return (plugin_unregister (list_flush, name));
+ llentry_t *e;
+ flush_func_t *ff;
+
+ e = llist_search (list_flush, name);
+
+ if (e == NULL)
+ return (-1);
+
+ llist_remove (list_flush, e);
+
+ ff = (flush_func_t *) e->value;
+ plugin_user_data_destroy (&ff->udata);
+ free (ff);
+ free (e->key);
+
+ llentry_destroy (e);
+
+ return (0);
}
int plugin_unregister_shutdown (const char *name)
int plugin_flush (const char *plugin, int timeout, const char *identifier)
{
- int (*callback) (int timeout, const char *identifier);
llentry_t *le;
if (list_flush == NULL)
le = llist_head (list_flush);
while (le != NULL)
{
+ flush_func_t *ff;
+
if ((plugin != NULL)
&& (strcmp (plugin, le->key) != 0))
{
continue;
}
- callback = (int (*) (int, const char *)) le->value;
- (*callback) (timeout, identifier);
+ ff = (flush_func_t *) le->value;
+
+ ff->callback (timeout, identifier, &ff->udata);
le = le->next;
}
diff --git a/src/plugin.h b/src/plugin.h
index e58444ff40fd39a2f65eda384ddeea5a97a9574a..ed9fdab7d3d1b624e45e113be11ba186a2b0234d 100644 (file)
--- a/src/plugin.h
+++ b/src/plugin.h
typedef int (*plugin_read_cb) (user_data_t *);
typedef int (*plugin_write_cb) (const data_set_t *, const value_list_t *,
user_data_t *);
+typedef int (*plugin_flush_cb) (int timeout, const char *identifier,
+ user_data_t *);
/*
* NAME
int plugin_register_write (const char *name,
plugin_write_cb callback, user_data_t *user_data);
int plugin_register_flush (const char *name,
- int (*callback) (const int timeout, const char *identifier));
+ plugin_flush_cb callback, user_data_t *user_data);
int plugin_register_shutdown (char *name,
int (*callback) (void));
int plugin_register_data_set (const data_set_t *ds);
diff --git a/src/rrdtool.c b/src/rrdtool.c
index 698f89fdb50970a451dfa2b1c9def70cbbb1fcfa..6ddbfc9e88594fb4c4137df1554b7dd6876acbf1 100644 (file)
--- a/src/rrdtool.c
+++ b/src/rrdtool.c
return (status);
} /* int rrd_write */
-static int rrd_flush (int timeout, const char *identifier)
+static int rrd_flush (int timeout, const char *identifier,
+ user_data_t __attribute__((unused)) *user_data)
{
pthread_mutex_lock (&cache_lock);
config_keys, config_keys_num);
plugin_register_init ("rrdtool", rrd_init);
plugin_register_write ("rrdtool", rrd_write, /* user_data = */ NULL);
- plugin_register_flush ("rrdtool", rrd_flush);
+ plugin_register_flush ("rrdtool", rrd_flush, /* user_data = */ NULL);
plugin_register_shutdown ("rrdtool", rrd_shutdown);
}