summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0aad516)
raw | patch | inline | side by side (parent: 0aad516)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 27 Apr 2008 18:53:49 +0000 (20:53 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 30 Apr 2008 08:40:50 +0000 (10:40 +0200) |
Perl plugins may now register a callback of type Collectd::TYPE_FLUSH. A
single integer argument, representing the timeout in seconds, will be
passed to such callbacks.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
single integer argument, representing the timeout in seconds, will be
passed to such callbacks.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
bindings/perl/Collectd.pm | patch | blob | history | |
src/perl.c | patch | blob | history |
index 43775706c3b8ccc6af6929a0d623b7145496f692..399fca84fa592c3e37ff4974b8f55d1b745f9036 100644 (file)
TYPE_SHUTDOWN
TYPE_LOG
TYPE_NOTIF
+ TYPE_FLUSH
TYPE_DATASET
) ],
'ds_types' => [ qw(
TYPE_WRITE, "write",
TYPE_SHUTDOWN, "shutdown",
TYPE_LOG, "log",
- TYPE_NOTIF, "notify"
+ TYPE_NOTIF, "notify",
+ TYPE_FLUSH, "flush"
);
foreach my $type (keys %types) {
diff --git a/src/perl.c b/src/perl.c
index 96e85622445da09a7b9ad8deae514e215d279e6f..beea288afc6bc154cedadd62de83da0b7558979a 100644 (file)
--- a/src/perl.c
+++ b/src/perl.c
#define PLUGIN_SHUTDOWN 3
#define PLUGIN_LOG 4
#define PLUGIN_NOTIF 5
+#define PLUGIN_FLUSH 6
-#define PLUGIN_TYPES 6
+#define PLUGIN_TYPES 7
#define PLUGIN_DATASET 255
{ "Collectd::TYPE_SHUTDOWN", PLUGIN_SHUTDOWN },
{ "Collectd::TYPE_LOG", PLUGIN_LOG },
{ "Collectd::TYPE_NOTIF", PLUGIN_NOTIF },
+ { "Collectd::TYPE_FLUSH", PLUGIN_FLUSH },
{ "Collectd::TYPE_DATASET", PLUGIN_DATASET },
{ "Collectd::DS_TYPE_COUNTER", DS_TYPE_COUNTER },
{ "Collectd::DS_TYPE_GAUGE", DS_TYPE_GAUGE },
XPUSHs (sv_2mortal (newRV_noinc ((SV *)notif)));
}
+ else if (PLUGIN_FLUSH == type) {
+ /*
+ * $_[0] = $timeout;
+ */
+ XPUSHs (sv_2mortal (newSViv (va_arg (ap, int))));
+ }
PUTBACK;
return pplugin_call_all (aTHX_ PLUGIN_NOTIF, notif);
} /* static int perl_notify (const notification_t *) */
+static int perl_flush (const int timeout)
+{
+ dTHX;
+
+ if (NULL == perl_threads)
+ return 0;
+
+ if (NULL == aTHX) {
+ c_ithread_t *t = NULL;
+
+ pthread_mutex_lock (&perl_threads->mutex);
+ t = c_ithread_create (perl_threads->head->interp);
+ pthread_mutex_unlock (&perl_threads->mutex);
+
+ aTHX = t->interp;
+ }
+ return pplugin_call_all (aTHX_ PLUGIN_FLUSH, timeout);
+} /* static int perl_flush (const int) */
+
static int perl_shutdown (void)
{
c_ithread_t *t = NULL;
plugin_unregister_init ("perl");
plugin_unregister_read ("perl");
plugin_unregister_write ("perl");
+ plugin_unregister_flush ("perl");
ret = pplugin_call_all (aTHX_ PLUGIN_SHUTDOWN);
plugin_register_read ("perl", perl_read);
plugin_register_write ("perl", perl_write);
+ plugin_register_flush ("perl", perl_flush);
plugin_register_shutdown ("perl", perl_shutdown);
return 0;
} /* static int init_pi (const char **, const int) */