plugin interface: If an init-function fails, write an error to syslog and remove...
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 4 Feb 2007 09:14:35 +0000 (10:14 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 4 Feb 2007 09:14:35 +0000 (10:14 +0100)
src/plugin.c

index 2daeea9..1a029e4 100644 (file)
@@ -317,6 +317,7 @@ void plugin_init_all (void)
 {
        int (*callback) (void);
        llentry_t *le;
+       int status;
 
        gethostname (hostname, sizeof (hostname));
 
@@ -327,7 +328,16 @@ void plugin_init_all (void)
        while (le != NULL)
        {
                callback = le->value;
-               (*callback) ();
+               status = (*callback) ();
+
+               if (status != 0)
+               {
+                       syslog (LOG_ERR, "Initialization of plugin `%s' "
+                                       "failed with status %i. "
+                                       "Plugin will be unloaded. TODO!",
+                                       le->key, status);
+                       plugin_unregister_read (le->key);
+               }
 
                le = le->next;
        }