NetworkManager/src/devices
Thomas Haller d8a31794c8 connectivity: rework async connectivity check requests
An asynchronous request should either be cancellable or not keep
the target object alive. Preferably both.

Otherwise, it is impossible to do a controlled shutdown when terminating
NetworkManager. Currently, when NetworkManager is about to terminate,
it just quits the mainloop and essentially leaks everything. That is a
bug. If we ever want to fix that, every asynchronous request must be
cancellable in a controlled way (or it must not prevent objects from
getting disposed, where disposing the object automatically cancels the
callback).

Rework the asynchronous request for connectivity check to

- return a handle that can be used to cancel the operation.
  Cancelling is optional. The caller may choose to ignore the handle
  because the asynchronous operation does not keep the target object
  alive. That means, it is still possible to shutdown, by everybody
  giving up their reference to the target object. In which case the
  callback will be invoked during dispose() of the target object.

- also, the callback will always be invoked exactly once, and never
  synchronously from within the asynchronous start call. But during
  cancel(), the callback is invoked synchronously from within cancel().
  Note that it's only allowed to cancel an action at most once, and
  never after the callback is invoked (also not from within the callback
  itself).

- also, NMConnectivity already supports a fake handler, in case
  connectivity check is disabled via configuration. Hence, reuse
  the same code paths also when compiling without --enable-concheck.
  That means, instead of having #if WITH_CONCHECK at various callers,
  move them into NMConnectivity. The downside is, that if you build
  without concheck, there is a small overhead compared to before. The
  upside is, we reuse the same code paths when compiling with or without
  concheck.

- also, the patch synchronizes the connecitivty states. For example,
  previously `nmcli networking connectivity check` would schedule
  requests in parallel, and return the accumulated result of the individual
  requests.
  However, the global connectivity state of the manager might have have
  been the same as the answer to the explicit connecitivity check,
  because while the answer for the manual check is waiting for all
  pending checks to complete, the global connectivity state could
  already change. That is just wrong. There are not multiple global
  connectivity states at the same time, there is just one. A manual
  connectivity check should have the meaning of ensure that the global
  state is up to date, but it still should return the global
  connectivity state -- not the answers for several connectivity checks
  issued in parallel.
  This is related to commit b799de281b
  (libnm: update property in the manager after connectivity check),
  which tries to address a similar problem client side.
  Similarly, each device has a connectivity state. While there might
  be several connectivity checks per device pending, whenever a check
  completes, it can update the per-device state (and return that device
  state as result), but the immediate answer of the individual check
  might not matter. This is especially the case, when a later request
  returns earlier and obsoletes all earlier requests. In that case,
  earlier requests return with the result of the currend devices
  connectivity state.

This patch cleans up the internal API and gives a better defined behavior
to the user (thus, the simple API which simplifies implementation for the
caller). However, the implementation of getting this API right and properly
handle cancel and destruction of the target object is more complicated and
complex. But this but is not just for the sake of a nicer API. This fixes
actual issues explained above.

Also, get rid of GAsyncResult to track information about the pending request.
Instead, allocate our own handle structure, which ends up to be nicer
because it's strongly typed and has exactly the properties that are
useful to track the request. Also, it gets rid of the awkward
_finish() API by passing the relevant arguments to the callback
directly.
2018-04-10 15:11:23 +02:00
..
adsl core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
bluetooth core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
ovs all: avoid calling g_free on a const pointer with g_clear_pointer() 2018-03-19 15:45:46 +01:00
team core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
tests platform: support creating non-persistant TUN/TAP devices 2018-04-09 20:16:31 +02:00
wifi device/trival: rename NMIwdManagerPrivate.nm_manager field to "manager" 2018-04-04 14:02:13 +02:00
wwan core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
meson.build build: add initial support for meson build system 2017-12-13 15:48:50 +01:00
nm-arping-manager.c all: use nm_direct_hash() instead of g_direct_hash() 2017-11-16 11:49:52 +01:00
nm-arping-manager.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-device-bond.c core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
nm-device-bond.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-device-bridge.c core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
nm-device-bridge.h bridge: move the Bluetooth NAP logic to bridge device 2017-06-01 11:57:42 +02:00
nm-device-dummy.c core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
nm-device-dummy.h core: add support for dummy devices 2017-02-22 21:05:04 +01:00
nm-device-ethernet-utils.c device: use NMSettings directly instead of NMConnectionProvider in subclasses 2016-05-24 12:35:58 +02:00
nm-device-ethernet-utils.h device: use NMSettings directly instead of NMConnectionProvider in subclasses 2016-05-24 12:35:58 +02:00
nm-device-ethernet.c core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
nm-device-ethernet.h all: replace non-leading tabs with spaces 2018-02-07 13:32:04 +01:00
nm-device-factory.c device: split per-directory factory function 2018-01-10 11:01:46 +01:00
nm-device-factory.h core: device-factory: implement match_connection() 2017-08-05 08:03:16 +02:00
nm-device-generic.c core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-generic.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-device-infiniband.c core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
nm-device-infiniband.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-device-ip-tunnel.c core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
nm-device-ip-tunnel.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-logging.h Revert "device: log device type too" 2017-10-31 18:48:41 +01:00
nm-device-macsec.c core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-macsec.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-macvlan.c core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
nm-device-macvlan.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-ppp.c core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-ppp.h device: add NMDevicePPP 2017-08-05 08:03:15 +02:00
nm-device-private.h all: replace non-leading tabs with spaces 2018-02-07 13:32:04 +01:00
nm-device-tun.c platform: support creating non-persistant TUN/TAP devices 2018-04-09 20:16:31 +02:00
nm-device-tun.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-device-veth.c core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-veth.h all: cleanup includes in header files 2016-08-17 19:51:17 +02:00
nm-device-vlan.c core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
nm-device-vlan.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device-vxlan.c core: avoid clone of all-connections list for nm_utils_complete_generic() 2018-03-20 15:08:18 +01:00
nm-device-vxlan.h core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API 2018-03-12 18:37:08 +01:00
nm-device.c connectivity: rework async connectivity check requests 2018-04-10 15:11:23 +02:00
nm-device.h connectivity: rework async connectivity check requests 2018-04-10 15:11:23 +02:00
nm-lldp-listener.c all: use nm_utils_hash_keys_to_array() 2018-03-27 09:58:00 +02:00
nm-lldp-listener.h core: refactor private data for NMExportedObject and others 2016-10-03 12:04:14 +02:00