summaryrefslogtreecommitdiff
path: root/src/nm-active-connection.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-02-11 08:36:39 +0100
committerThomas Haller <thaller@redhat.com>2016-02-16 11:24:49 +0100
commitb96a40c2ec9e4318e7d2a578396236f68e487710 (patch)
treeb0e3e9e8005b79d8ae13499e7d22c877c5032045 /src/nm-active-connection.c
parent4b76d866981b65f9e9ee282dc901ab907f546221 (diff)
downloadNetworkManager-b96a40c2ec9e4318e7d2a578396236f68e487710.tar.gz
core: add version-id to NMActiveConnection
This field will be later used by NMDevice's Reapply and GetAppliedConnection methods. The usecase is to first fetch the currently applied connection, adjust it and reapply it. Using the version-id, a concurrent modification can be detected and Reapply can reject the invocation.
Diffstat (limited to 'src/nm-active-connection.c')
-rw-r--r--src/nm-active-connection.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index 91068e56a7..f7506022a1 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -46,6 +46,8 @@ typedef struct {
char *specific_object;
NMDevice *device;
+ guint64 version_id;
+
char *pending_activation_id;
gboolean is_default;
@@ -796,10 +798,45 @@ nm_active_connection_authorize (NMActiveConnection *self,
/****************************************************************/
+static guint64
+_version_id_new (void)
+{
+ static guint64 id = 0;
+
+ return ++id;
+}
+
+guint64
+nm_active_connection_version_id_get (NMActiveConnection *self)
+{
+ g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), 0);
+
+ return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->version_id;
+}
+
+guint64
+nm_active_connection_version_id_bump (NMActiveConnection *self)
+{
+ NMActiveConnectionPrivate *priv;
+
+ g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), 0);
+
+ priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
+ priv->version_id = _version_id_new ();
+ _LOGT ("new version-id %llu", (long long unsigned) priv->version_id);
+ return priv->version_id;
+}
+
+/****************************************************************/
+
static void
nm_active_connection_init (NMActiveConnection *self)
{
+ NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
+
_LOGT ("creating");
+
+ priv->version_id = _version_id_new ();
}
static void
@@ -810,7 +847,7 @@ constructed (GObject *object)
G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object);
- _LOGD ("constructed (%s)", G_OBJECT_TYPE_NAME (self));
+ _LOGD ("constructed (%s, version-id %llu)", G_OBJECT_TYPE_NAME (self), (long long unsigned) priv->version_id);
g_return_if_fail (priv->subject);
}