X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fplugin.c;h=cf0384918a7e8eec902094d6f88d46053ee5b116;hb=a813e8af8379bd0f55a2b46fc7918fa31de9522e;hp=0570f0ee0dc37269ce66fb724fe7f6abd64ac7dc;hpb=4f2642f86673329db9f8cf30854bf39bbdc4c2b2;p=collectd.git diff --git a/src/plugin.c b/src/plugin.c index 0570f0ee..cf038491 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -1,6 +1,6 @@ /** * collectd - src/plugin.c - * Copyright (C) 2005,2006 Florian octo Forster + * Copyright (C) 2005-2008 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -17,6 +17,7 @@ * * Authors: * Florian octo Forster + * Sebastian Harl **/ #include "collectd.h" @@ -53,6 +54,7 @@ typedef struct read_func_s read_func_t; static llist_t *list_init; static llist_t *list_read; static llist_t *list_write; +static llist_t *list_flush; static llist_t *list_shutdown; static llist_t *list_log; static llist_t *list_notification; @@ -434,6 +436,11 @@ int plugin_register_write (const char *name, return (register_callback (&list_write, name, (void *) callback)); } /* int plugin_register_write */ +int plugin_register_flush (const char *name, int (*callback) (const int)) +{ + return (register_callback (&list_flush, name, (void *) callback)); +} /* int plugin_register_flush */ + int plugin_register_shutdown (char *name, int (*callback) (void)) { @@ -528,6 +535,11 @@ int plugin_unregister_write (const char *name) return (plugin_unregister (list_write, name)); } +int plugin_unregister_flush (const char *name) +{ + return (plugin_unregister (list_flush, name)); +} + int plugin_unregister_shutdown (const char *name) { return (plugin_unregister (list_shutdown, name)); @@ -640,6 +652,43 @@ void plugin_read_all (void) pthread_mutex_unlock (&read_lock); } /* void plugin_read_all */ +int plugin_flush_one (int timeout, const char *name) +{ + int (*callback) (int); + llentry_t *le; + int status; + + if (list_flush == NULL) + return (-1); + + le = llist_search (list_flush, name); + if (le == NULL) + return (-1); + callback = (int (*) (int)) le->value; + + status = (*callback) (timeout); + + return (status); +} /* int plugin_flush_ont */ + +void plugin_flush_all (int timeout) +{ + int (*callback) (int); + llentry_t *le; + + if (list_flush == NULL) + return; + + le = llist_head (list_flush); + while (le != NULL) + { + callback = (int (*) (int)) le->value; + le = le->next; + + (*callback) (timeout); + } +} /* void plugin_flush_all */ + void plugin_shutdown_all (void) { int (*callback) (void);