NetworkManager/src/libnm-client-public
Thomas Haller 88724ff169
libnm: add nm_client_wait_shutdown() function for cleaning up NMClient
Add a fire-and-forget function to wait for shutdown to be complete.

It's not entirely trivial to ensure all resources of NMClient are
cleaned up. That matters only if NMClient uses a temporary GMainContext
that the user wants to release while the application continues. For
example, to do some short-lived operations an a worker thread. It's
not trivial also because glib provides no convenient API to integrate
a GMainContext in another GMainContext. We have that code as
nm_utils_g_main_context_create_integrate_source(), so add a helper
function to allow the user to do this.

The function allows to omit the callback, in which case the caller
wouldn't know when shutdown is complete. That would still be useful
however, when integrating the client's context into the caller's
context, so that the client's context gets automatically iterated
until completion.

The following test script will run out of file descriptors,
when wait_shutdown() is not used:

   #!/bin/python

   import gi

   gi.require_version("NM", "1.0")
   from gi.repository import NM, GLib

   for i in range(1200):
       print(f">>>{i}")

       ctx = GLib.MainContext()
       ctx.push_thread_default()
       nmc = NM.Client.new()
       ctx.pop_thread_default()

       def cb(unused, result, i):
           try:
               NM.Client.wait_shutdown_finish(result)
           except Exception:
               # cannot happen
               assert False
           else:
               print(f">>>>> {i} complete")

       nmc.wait_shutdown(True, None, cb, i)

       while GLib.MainContext.default().iteration(False):
           pass
2022-10-14 17:48:24 +02:00
..
meson.build libnm-client: Add public nm_conn_wireguard_import() func 2022-07-21 14:53:26 +02:00
NetworkManager.h libnm-client: Add public nm_conn_wireguard_import() func 2022-07-21 14:53:26 +02:00
nm-access-point.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-active-connection.h libnm: avoid duplicate typedefs for NMClient/NMDevice 2022-05-12 15:47:57 +02:00
nm-autoptr.h bond: add support of queue_id of bond port 2021-08-26 23:04:31 +02:00
nm-checkpoint.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-client.h libnm: add nm_client_wait_shutdown() function for cleaning up NMClient 2022-10-14 17:48:24 +02:00
nm-conn-utils.h libnm-client: Add public nm_conn_wireguard_import() func 2022-07-21 14:53:26 +02:00
nm-device-6lowpan.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-adsl.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-bond.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-bridge.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-bt.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-dummy.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-ethernet.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-generic.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-infiniband.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-ip-tunnel.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-macsec.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-macvlan.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-modem.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-olpc-mesh.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-ovs-bridge.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-ovs-interface.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-ovs-port.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-ppp.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-team.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-tun.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-veth.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-vlan.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-vrf.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-vxlan.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-wifi-p2p.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-wifi.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-wimax.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-wireguard.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device-wpan.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-device.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-dhcp-config.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-enum-types.c.template libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-enum-types.h.template build: move "libnm/" to "src/" and split it 2021-02-24 12:48:37 +01:00
nm-ethtool-utils.h lgtm: suppress lgtm[cpp/duplicate-include-guard] warning in ethtool header 2021-06-01 17:54:07 +02:00
nm-ip-config.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-object.h libnm: avoid duplicate typedefs for NMClient/NMDevice 2022-05-12 15:47:57 +02:00
nm-remote-connection.h libnm: undeprecate nm_remote_connection_get_secrets() 2022-08-25 15:28:18 +02:00
nm-secret-agent-old.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-vpn-connection.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-vpn-editor.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-vpn-plugin-old.h libnm: drop NM_DEPRECATED_IN_1_2/NM_AVAILABLE_IN_1_2 macros from structs in libnm headers 2022-04-28 16:39:42 +02:00
nm-vpn-service-plugin.h libnm: drop NM_DEPRECATED_IN_1_2/NM_AVAILABLE_IN_1_2 macros from structs in libnm headers 2022-04-28 16:39:42 +02:00
nm-wifi-p2p-peer.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
nm-wimax-nsp.h libnm: replace nm-types.h by defining the types in respective headers 2022-05-06 18:33:27 +02:00
README.md all: add some README.md files describing the purpose of our sources 2021-08-19 17:51:11 +02:00

libnm-client-public

libnm is NetworkManager's client API. It has a public API. This API consists of two parts:

  • the handling of connections (NMConnection), implemented by libnm-core-impl.
  • the caching of D-Bus API (NMClient), implemented by libnm-client-impl.

This directory contains public headers that are used by libnm users. As such, it's the NMClient part of libnm-core-public.

These headers are usable to any libnm client application and to libnm itself. But not to libnm-core-impl or the daemon.