l3cfg: minor adjustments for L3Cfg code

This commit is contained in:
Thomas Haller 2021-05-21 21:24:32 +02:00
parent 1ce02ffd50
commit 8258ce6cf6
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 25 additions and 4 deletions

View file

@ -2582,18 +2582,19 @@ _l3_commit_on_idle_cb(gpointer user_data)
return G_SOURCE_REMOVE;
}
void
gboolean
nm_l3cfg_commit_on_idle_schedule(NML3Cfg *self)
{
nm_assert(NM_IS_L3CFG(self));
if (self->priv.p->commit_on_idle_source)
return;
return FALSE;
_LOGT("commit on idle (scheduled)");
self->priv.p->commit_on_idle_source =
nm_g_idle_source_new(G_PRIORITY_DEFAULT, _l3_commit_on_idle_cb, self, NULL);
g_source_attach(self->priv.p->commit_on_idle_source, NULL);
return TRUE;
}
/*****************************************************************************/
@ -3697,6 +3698,23 @@ _nm_l3cfg_unregister_ipv4ll(NML3Cfg *self)
/*****************************************************************************/
gboolean
nm_l3cfg_is_ready(NML3Cfg *self)
{
g_return_val_if_fail(NM_IS_L3CFG(self), FALSE);
if (self->priv.p->changed_configs_configs)
return FALSE;
if (self->priv.p->changed_configs_acd_state)
return FALSE;
if (self->priv.p->commit_on_idle_source)
return FALSE;
return TRUE;
}
/*****************************************************************************/
static void
set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{

View file

@ -98,7 +98,8 @@ typedef enum {
NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT,
/* emitted at the end of nm_l3cfg_platform_commit(). */
/* emitted at the end of nm_l3cfg_platform_commit(). This signals also that
* nm_l3cfg_is_ready() might have switched to TRUE. */
NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT,
/* NML3Cfg hooks to the NMPlatform signals for link, addresses and routes.
@ -170,6 +171,8 @@ NML3Cfg *nm_l3cfg_new(NMNetns *netns, int ifindex);
/*****************************************************************************/
gboolean nm_l3cfg_is_ready(NML3Cfg *self);
void _nm_l3cfg_notify_platform_change_on_idle(NML3Cfg *self, guint32 obj_type_flags);
void _nm_l3cfg_notify_platform_change(NML3Cfg * self,
@ -328,7 +331,7 @@ typedef enum _nm_packed {
void nm_l3cfg_commit(NML3Cfg *self, NML3CfgCommitType commit_type);
void nm_l3cfg_commit_on_idle_schedule(NML3Cfg *self);
gboolean nm_l3cfg_commit_on_idle_schedule(NML3Cfg *self);
/*****************************************************************************/