summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 79a87c3)
raw | patch | inline | side by side (parent: 79a87c3)
author | Florian Forster <octo@huhu.verplant.org> | |
Tue, 11 Jan 2011 07:57:08 +0000 (08:57 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 11 Jan 2011 07:57:08 +0000 (08:57 +0100) |
This way the error message is much closer to the check and we save one
level of indentation for the "good" code.
level of indentation for the "good" code.
src/plugin.c | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index 52a5ea088cfb9537e5d5c8f2f0b7e905413cf6b4..eb98a7a33a3944ccf5851147e6e96f702c0d1b62 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
/**
* collectd - src/plugin.c
- * Copyright (C) 2005-2010 Florian octo Forster
+ * Copyright (C) 2005-2011 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
}
le = llist_search (read_list, rf->rf_name);
- if (le == NULL)
+ if (le != NULL)
{
- le = llentry_create (rf->rf_name, rf);
- if (le == NULL)
- {
- pthread_mutex_unlock (&read_lock);
- ERROR ("plugin_insert_read: llentry_create failed.");
- return (-1);
- }
-
- status = c_heap_insert (read_heap, rf);
- if (status != 0)
- {
- pthread_mutex_unlock (&read_lock);
- ERROR ("plugin_insert_read: c_heap_insert failed.");
- llentry_destroy (le);
- return (-1);
- }
+ pthread_mutex_unlock (&read_lock);
+ WARNING ("The read function \"%s\" is already registered. "
+ "Check for duplicate \"LoadPlugin\" lines "
+ "in your configuration!",
+ rf->rf_name);
+ return (EINVAL);
+ }
- /* This does not fail. */
- llist_append (read_list, le);
+ le = llentry_create (rf->rf_name, rf);
+ if (le == NULL)
+ {
+ pthread_mutex_unlock (&read_lock);
+ ERROR ("plugin_insert_read: llentry_create failed.");
+ return (-1);
}
- else
+
+ status = c_heap_insert (read_heap, rf);
+ if (status != 0)
{
- INFO ("plugin: plugin_insert_read: "
- "read function for plugin `%s' already added.",
- rf->rf_name);
+ pthread_mutex_unlock (&read_lock);
+ ERROR ("plugin_insert_read: c_heap_insert failed.");
+ llentry_destroy (le);
+ return (-1);
}
+ /* This does not fail. */
+ llist_append (read_list, le);
+
pthread_mutex_unlock (&read_lock);
return (0);
} /* int plugin_insert_read */