The types NMBridgeVlan, NMIPRoutingRule, NMRange, NMWireGuardPeer
are immutable (or immutable, after the seal() function is called).
Immutable types are great, as it means a reference to them can be shared
without doing a full clone. Hence the G_DEFINE_BOXED_TYPE() for these
types prefers to take a reference instead of cloning the objects. Except
for sealable types, where it will prefer to clone unsealed values.
Likewise, nm_simple_connection_new_clone() probably will just take
another reference to the value, instead of doing a deep clone.
libnm is not a thread-safe library in the sense that you could pass a
NMConnection or NMClient instance to multiple threads and access them
without your own synchronization. However, it should be possible that
multiple threads access (seemingly) distinct objects.
As the copy function of these boxed types (and nm_simple_connection_new_clone()
and similar) prefers to share the references to immutable types, it is important
that the ref function is thread-safe too. Otherwise you cannot just clone a
NMConnection on thread1, hand the clone to thread2 and operate on the
clone and the original independently. If you do before this patch, you would
hit a subtle race condition.
Avoid that. While atomic operations have a runtime overhead, being safe
is more important. Also, we already save a full malloc()/free() by
having immutable, ref-counted types. We just need to make it safe to use
in order to fully benefit from it.
NetworkManager provides a client library libnm.
NetworkManager core does not (dynamically) link against all of libnm.
Instead, it statically links against a part of it.
That part is the static helper library libnm-core-impl.
libnm-core-impl implements (and provides) the API from
libnm-core-public, which is part of the public
API of libnm. In this form, libnm-core-impl is part
of the implementation of libnm. It also implements (and
provides) an internal API libnm-core-intern which
can only be used by those who link statically against libnm-core-impl.
Only NetworkManager core and libnm are allowed to statically
link with libnm-core-impl. Consequently, only those are allowed to include
libnm-core-intern.
This directory should not be added to the include search path of other
components as they are only allowed to include libnm-core-public
and libnm-core-intern.