settings: don't implement settings plugins as singletons
The settings plugins are created by NMSettings when the plugin gets loaded. There is no need for these instances to be singletons or to have a singleton getter. Also, while in practice we create a settings plugin instance of each type only once, there is nothing that would prevent creating multiple instances. Hence, having a singleton getter is not right. What is however useful, is to track them and block shutdown via nm_shutdown_wait_obj_register*(). While the actual waiting is not yet implemented, we should mark the plugin instances to block shutdown (in the future).
This commit is contained in:
@@ -126,6 +126,8 @@ static void
|
||||
_nm_singleton_instance_weak_cb (gpointer data,
|
||||
GObject *where_the_object_was)
|
||||
{
|
||||
nm_assert (g_slist_find (_singletons, where_the_object_was));
|
||||
|
||||
_singletons = g_slist_remove (_singletons, where_the_object_was);
|
||||
}
|
||||
|
||||
|
@@ -1255,6 +1255,10 @@ add_plugin (NMSettings *self,
|
||||
|
||||
priv->plugins = g_slist_append (priv->plugins, g_object_ref (plugin));
|
||||
|
||||
nm_shutdown_wait_obj_register_full (G_OBJECT (plugin),
|
||||
g_strdup_printf ("%s-settings-plugin", pname),
|
||||
TRUE);
|
||||
|
||||
_LOGI ("Loaded settings plugin: %s (%s%s%s)",
|
||||
pname,
|
||||
NM_PRINT_FMT_QUOTED (path, "\"", path, "\"", "internal"));
|
||||
|
@@ -79,12 +79,6 @@ G_DEFINE_TYPE (SettingsPluginIfcfg, settings_plugin_ifcfg, NM_TYPE_SETTINGS_PLUG
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static SettingsPluginIfcfg *settings_plugin_ifcfg_get (void);
|
||||
|
||||
NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfcfg, settings_plugin_ifcfg_get, SETTINGS_TYPE_PLUGIN_IFCFG);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NMLOG_DOMAIN LOGD_SETTINGS
|
||||
#define _NMLOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
@@ -984,5 +978,5 @@ settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *klass)
|
||||
G_MODULE_EXPORT NMSettingsPlugin *
|
||||
nm_settings_plugin_factory (void)
|
||||
{
|
||||
return NM_SETTINGS_PLUGIN (g_object_ref (settings_plugin_ifcfg_get ()));
|
||||
return g_object_new (SETTINGS_TYPE_PLUGIN_IFCFG, NULL);
|
||||
}
|
||||
|
@@ -75,11 +75,6 @@ G_DEFINE_TYPE (SettingsPluginIfupdown, settings_plugin_ifupdown, NM_TYPE_SETTING
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static SettingsPluginIfupdown *settings_plugin_ifupdown_get (void);
|
||||
NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfupdown, settings_plugin_ifupdown_get, SETTINGS_TYPE_PLUGIN_IFUPDOWN);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NMLOG_PREFIX_NAME "ifupdown"
|
||||
#define _NMLOG_DOMAIN LOGD_SETTINGS
|
||||
#define _NMLOG(level, ...) \
|
||||
@@ -339,5 +334,5 @@ settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *klass)
|
||||
G_MODULE_EXPORT NMSettingsPlugin *
|
||||
nm_settings_plugin_factory (void)
|
||||
{
|
||||
return NM_SETTINGS_PLUGIN (g_object_ref (settings_plugin_ifupdown_get ()));
|
||||
return g_object_new (SETTINGS_TYPE_PLUGIN_IFUPDOWN, NULL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user