From 4d89b519b4c889859a84780a18dbb2f12c9a9438 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 31 Mar 2010 03:05:22 -0700 Subject: [PATCH] core: don't advance to next plugin until needed Otherwise info->cur_plugin is wrong (and therefore we left uncleared supports tasks in MMPluginBase) when the port isn't supported by the plugin, but it's parent modem device was supported by the plugin. Like when all probing of the port fails but one of it's siblings has already been claimed by a modem; in this case we just drop the port (so that no other plugin could try to claim it, because only one plugin is allowed to handle all a modem's ports) but we still need to tell the parent modem's plugin to clean up the supports task. --- src/mm-manager.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mm-manager.c b/src/mm-manager.c index 21b5b582..6a2485eb 100644 --- a/src/mm-manager.c +++ b/src/mm-manager.c @@ -564,10 +564,6 @@ supports_callback (MMPlugin *plugin, MMPlugin *next_plugin = NULL; MMModem *existing; - info->cur_plugin = info->cur_plugin->next; - if (info->cur_plugin) - next_plugin = MM_PLUGIN (info->cur_plugin->data); - /* Is this plugin's result better than any one we've tried before? */ if (level > info->best_level) { info->best_level = level; @@ -610,11 +606,20 @@ supports_callback (MMPlugin *plugin, next_plugin = existing_plugin; } else g_assert_not_reached (); + } else { + info->cur_plugin = info->cur_plugin->next; + if (info->cur_plugin->next) + next_plugin = MM_PLUGIN (info->cur_plugin->data); } if (next_plugin) { - /* Try the next plugin */ - try_supports_port (info->manager, next_plugin, existing, info); + const char *next_name = mm_plugin_get_name (next_plugin); + + /* Try the next plugin, but don't bother with the Generic plugin if + * something already supports this port. + */ + if (!info->best_plugin || strcmp (next_name, MM_PLUGIN_GENERIC_NAME)) + try_supports_port (info->manager, next_plugin, existing, info); } else { /* All done; let the best modem grab the port */ info->done_id = g_idle_add (do_grab_port, info);