The loading order of plugins

Ken CJ Chou kenchou0731 at gmail.com
Mon Oct 8 10:38:56 UTC 2018


Hi,
I'm now working on a modem "Cinterion Gemalto ELS61". And I tried to use it
with ModemManager.
ModemManager suggests the "Cinterion" plugin. But somehow, the AT command
set and some response message format of "Cinterion Gemalto ELS61" is
different from other modems supported by the "Cinterion" plugin. So I wrote
a plugin named "G-ELS61" especially for it.

The question is, both "Cinterion" plugin and "G-ELS61" plugin support modem
"Cinterion Gemalto ELS61". ModemManager will select the prior loaded plugin
as best-plugin.
While the order of loading plugins is not fixed in ModemManager (Since
"readdir()" returns entries in the order that files are linked in
filesystem). That means ModemManager may use different plugin for the same
modem on different devices.

Currently, I use a simple workaround to solve the issue. I sort the loading
order by the plugins' filename before loading. So that I can control the
loading order of my plugin by its filename. The diff log is attached below:

---
--- a/src/mm-plugin-manager.c
+++ b/src/mm-plugin-manager.c
@@ -56,6 +56,12 @@
     GList *device_contexts;
 };

+static gint compare_fname (gconstpointer a, gconstpointer b) {
+    gchar *fnameA = (gchar *) a;
+    gchar *fnameB = (gchar *) b;
+    return strcmp(fnameA, fnameB);
+}
+
 /*****************************************************************************/
 /* Build plugin list for a single port */

@@ -1544,6 +1550,7 @@
     GDir *dir = NULL;
     const gchar *fname;
     gchar *plugindir_display = NULL;
+    GList *plugins_fname = NULL, *iter;

     if (!g_module_supported ()) {
         g_set_error (error,
@@ -1568,13 +1575,17 @@
     }

     while ((fname = g_dir_read_name (dir)) != NULL) {
-        gchar *path;
-        MMPlugin *plugin;
-
         if (!g_str_has_suffix (fname, G_MODULE_SUFFIX))
             continue;
+        plugins_fname = g_list_append(plugins_fname, (gpointer) fname);
+    }
+    plugins_fname = g_list_sort (plugins_fname, compare_fname);
+
+    for (iter = plugins_fname; iter != NULL; iter = iter->next) {
+        gchar *path;
+        MMPlugin *plugin;

-        path = g_module_build_path (self->priv->plugin_dir, fname);
+        path = g_module_build_path (self->priv->plugin_dir, iter->data);
         plugin = load_plugin (path);
         g_free (path);

@@ -1590,6 +1601,7 @@
             /* Vendor specific plugin */
             self->priv->plugins = g_list_append (self->priv->plugins,
plugin);
     }
+    g_list_free (plugins_fname);

     /* Check the generic plugin once all looped */
     if (!self->priv->generic)

---

Any suggestion?

regards,
Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/modemmanager-devel/attachments/20181008/4d85a29d/attachment.html>


More information about the ModemManager-devel mailing list