pthread_mutex_unlock (&read_lock);
pthread_exit (NULL);
+ return ((void *) 0);
} /* void *plugin_read_thread */
static void start_threads (int num)
{
DIR *dh;
const char *dir;
- char filename[BUFSIZE];
+ char filename[BUFSIZE] = "";
char typename[BUFSIZE];
int typename_len;
int ret;
closedir (dh);
+ if (filename[0] == '\0')
+ fprintf (stderr, "Could not find plugin %s.\n", type);
+
return (ret);
}
llentry_t *le;
int status;
- /* Start read-threads */
- if (list_read != NULL)
- {
- const char *rt;
- int num;
- rt = global_option_get ("ReadThreads");
- num = atoi (rt);
- start_threads ((num > 0) ? num : 5);
- }
-
/* Init the value cache */
uc_init ();
- if (list_init == NULL)
+ if ((list_init == NULL) && (list_read == NULL))
return;
+ /* Calling all init callbacks before checking if read callbacks
+ * are available allows the init callbacks to register the read
+ * callback. */
le = llist_head (list_init);
while (le != NULL)
{
"failed with status %i. "
"Plugin will be unloaded.",
le->key, status);
+ /* Plugins that register read callbacks from the init
+ * callback should take care of appropriate error
+ * handling themselves. */
/* FIXME: Unload _all_ functions */
plugin_unregister_read (le->key);
}
le = le->next;
}
+
+ /* Start read-threads */
+ if (list_read != NULL)
+ {
+ const char *rt;
+ int num;
+ rt = global_option_get ("ReadThreads");
+ num = atoi (rt);
+ start_threads ((num > 0) ? num : 5);
+ }
} /* void plugin_init_all */
void plugin_read_all (void)
data_set_t *ds;
llentry_t *le;
- if ((list_write == NULL) || (data_sets == NULL))
+ if (list_write == NULL)
+ {
+ ERROR ("plugin_dispatch_values: No write callback has been "
+ "registered. Please load at least one plugin "
+ "that provides a write function.");
+ return (-1);
+ }
+
+ if (data_sets == NULL)
+ {
+ ERROR ("plugin_dispatch_values: No data sets registered. "
+ "Could the types database be read? Check "
+ "your `TypesDB' setting!");
return (-1);
+ }
if (c_avl_get (data_sets, name, (void *) &ds) != 0)
{
- DEBUG ("No such dataset registered: %s", name);
+ INFO ("plugin_dispatch_values: Dataset not found: %s", name);
return (-1);
}
- DEBUG ("plugin: plugin_dispatch_values: time = %u; interval = %i; "
+ DEBUG ("plugin_dispatch_values: time = %u; interval = %i; "
"host = %s; "
"plugin = %s; plugin_instance = %s; "
"type = %s; type_instance = %s;",
#else
if (ds->ds_num != vl->values_len)
{
- ERROR ("plugin: ds->type = %s: (ds->ds_num = %i) != "
+ ERROR ("plugin_dispatch_values: ds->type = %s: "
+ "(ds->ds_num = %i) != "
"(vl->values_len = %i)",
ds->type, ds->ds_num, vl->values_len);
return (-1);