platform: drop track_default argument from nmp_rules_manager_new()

All that setting track-default does, is calling nmp_rules_manager_track_default()
when the rules are first accessed.

That is not right API. Since nmp_rules_manager_track_default() is already public
API (good), every caller that wishes this behavior should track these routes explicitly.
This commit is contained in:
Thomas Haller
2019-04-10 12:52:56 +02:00
parent 6fe1a38de0
commit f281c62e53
4 changed files with 8 additions and 11 deletions

View File

@@ -126,7 +126,11 @@ constructed (GObject *object)
priv->platform_netns = nm_platform_netns_get (priv->platform); priv->platform_netns = nm_platform_netns_get (priv->platform);
priv->rules_manager = nmp_rules_manager_new (priv->platform, TRUE); priv->rules_manager = nmp_rules_manager_new (priv->platform);
nmp_rules_manager_track_default (priv->rules_manager,
AF_UNSPEC,
0,
nm_netns_parent_class /* static dummy user-tag */);
G_OBJECT_CLASS (nm_netns_parent_class)->constructed (object); G_OBJECT_CLASS (nm_netns_parent_class)->constructed (object);
} }

View File

@@ -33,7 +33,6 @@ struct _NMPRulesManager {
GHashTable *by_user_tag; GHashTable *by_user_tag;
GHashTable *by_data; GHashTable *by_data;
guint ref_count; guint ref_count;
bool track_default:1;
}; };
/*****************************************************************************/ /*****************************************************************************/
@@ -622,16 +621,12 @@ _rules_init (NMPRulesManager *self)
self->by_data = g_hash_table_new_full (_rules_data_hash, _rules_data_equal, NULL, _rules_data_destroy); self->by_data = g_hash_table_new_full (_rules_data_hash, _rules_data_equal, NULL, _rules_data_destroy);
self->by_obj = g_hash_table_new_full (_rules_obj_hash, _rules_obj_equal, NULL, _rules_obj_destroy); self->by_obj = g_hash_table_new_full (_rules_obj_hash, _rules_obj_equal, NULL, _rules_obj_destroy);
self->by_user_tag = g_hash_table_new_full (_rules_user_tag_hash, _rules_user_tag_equal, NULL, _rules_user_tag_destroy); self->by_user_tag = g_hash_table_new_full (_rules_user_tag_hash, _rules_user_tag_equal, NULL, _rules_user_tag_destroy);
if (self->track_default)
nmp_rules_manager_track_default (self, AF_UNSPEC, 0, &self->by_data);
} }
/*****************************************************************************/ /*****************************************************************************/
NMPRulesManager * NMPRulesManager *
nmp_rules_manager_new (NMPlatform *platform, nmp_rules_manager_new (NMPlatform *platform)
gboolean track_default)
{ {
NMPRulesManager *self; NMPRulesManager *self;
@@ -641,7 +636,6 @@ nmp_rules_manager_new (NMPlatform *platform,
*self = (NMPRulesManager) { *self = (NMPRulesManager) {
.ref_count = 1, .ref_count = 1,
.platform = g_object_ref (platform), .platform = g_object_ref (platform),
.track_default = track_default,
}; };
return self; return self;
} }

View File

@@ -24,8 +24,7 @@
typedef struct _NMPRulesManager NMPRulesManager; typedef struct _NMPRulesManager NMPRulesManager;
NMPRulesManager *nmp_rules_manager_new (NMPlatform *platform, NMPRulesManager *nmp_rules_manager_new (NMPlatform *platform);
gboolean track_default);
void nmp_rules_manager_ref (NMPRulesManager *self); void nmp_rules_manager_ref (NMPRulesManager *self);
void nmp_rules_manager_unref (NMPRulesManager *self); void nmp_rules_manager_unref (NMPRulesManager *self);

View File

@@ -1511,7 +1511,7 @@ again:
if (TEST_SYNC) { if (TEST_SYNC) {
gs_unref_hashtable GHashTable *unique_priorities = g_hash_table_new (NULL, NULL); gs_unref_hashtable GHashTable *unique_priorities = g_hash_table_new (NULL, NULL);
nm_auto_unref_rules_manager NMPRulesManager *rules_manager = nmp_rules_manager_new (platform, FALSE); nm_auto_unref_rules_manager NMPRulesManager *rules_manager = nmp_rules_manager_new (platform);
gs_unref_ptrarray GPtrArray *objs_sync = NULL; gs_unref_ptrarray GPtrArray *objs_sync = NULL;
gconstpointer USER_TAG_1 = &platform; gconstpointer USER_TAG_1 = &platform;
gconstpointer USER_TAG_2 = &unique_priorities; gconstpointer USER_TAG_2 = &unique_priorities;