]> git.e2factory.org Git - e2factory.git/commitdiff
plugin: remove call to abort()
authorTobias Ulmer <tu@emlix.com>
Wed, 17 Apr 2013 15:41:05 +0000 (17:41 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 13:58:55 +0000 (14:58 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/plugin.lua

index 4d97f696a040a287f1d92cd3e039340623299239..e8fb1ba3f339b71b0370ffe0295fc6fdb6b3deec 100644 (file)
@@ -162,8 +162,11 @@ end
 --- Depth first search visitor that does the sorting.
 local function plugin_dfs_visit(plugin, plugins, pluginsvisited, pluginssorted,
     cycledetect)
+
+    local rc, re
+
     if pluginsvisited[plugin] then
-        return
+        return true
     end
 
     pluginsvisited[plugin] = true
@@ -179,27 +182,37 @@ local function plugin_dfs_visit(plugin, plugins, pluginsvisited, pluginssorted,
                         c = " " .. p.file
                     end
                     e:append("somewhere in this branch:" .. c)
-                    e2lib.abort(e)
+                    return false, e
                 end
-                plugin_dfs_visit(pluginm, plugins, pluginsvisited,
+                rc, re = plugin_dfs_visit(pluginm, plugins, pluginsvisited,
                     pluginssorted, cycledetect)
+                if not rc then
+                    return false, re
+                end
             end
         end
     end
 
     table.insert(pluginssorted, 1,  plugin)
+
+    return true
 end
 
 --- Topological sort for plugins according to their dependencies.
--- When cycles are encountered, it aborts.
--- @return a sorted plugin table
+-- @return Sorted plugin table or false on error.
+-- @return Error object on failure.
 local function plugin_tsort(plugins)
+    local rc, re
     local pluginsvisited = {}
     local pluginssorted = {}
 
     for _, plugin in ipairs(plugins) do
         if not pluginsvisited[plugin] then
-            plugin_dfs_visit(plugin, plugins, pluginsvisited, pluginssorted, {})
+            rc, re = plugin_dfs_visit(plugin, plugins,
+                pluginsvisited, pluginssorted, {})
+            if not rc then
+                return false, re
+            end
         end
     end
 
@@ -211,8 +224,12 @@ end
 -- @return an error object on failure
 function plugin.init_plugins()
     local e = err.new("initializing plugins failed")
+    local re
 
-    plugins = plugin_tsort(plugins)
+    plugins, re = plugin_tsort(plugins)
+    if not plugins then
+        return false, e:cat(re)
+    end
 
     for _, pd in ipairs(plugins) do
         e2lib.logf(4, "init plugin %s", pd.file)