diff options
author | Thomas Haller <thaller@redhat.com> | 2021-04-23 16:44:34 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-04-28 13:20:02 +0200 |
commit | 92f742f66bfbd0f6b40662d31dbd3b59a8c73129 (patch) | |
tree | cfa28fc80449e04ec36c0da06bdeb9011dfca863 | |
parent | 42938a7f5244aecde6bb77111302dcb760bdf2be (diff) | |
download | NetworkManager-92f742f66bfbd0f6b40662d31dbd3b59a8c73129.tar.gz |
dns/resolved: add ensure_resolved_running() helper method
Factor out the code. We will use it next.
-rw-r--r-- | src/core/dns/nm-dns-systemd-resolved.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/core/dns/nm-dns-systemd-resolved.c b/src/core/dns/nm-dns-systemd-resolved.c index 2a8a228900..765171c3cd 100644 --- a/src/core/dns/nm-dns-systemd-resolved.c +++ b/src/core/dns/nm-dns-systemd-resolved.c @@ -323,20 +323,14 @@ prepare_one_interface(NMDnsSystemdResolved *self, InterfaceConfig *ic) return has_config; } -static void -send_updates(NMDnsSystemdResolved *self) +static NMTernary +ensure_resolved_running(NMDnsSystemdResolved *self) { NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); - RequestItem * request_item; - - if (!priv->request_queue_to_send) { - /* nothing to do. */ - return; - } if (!priv->dbus_initied) { _LOGT("send-updates: D-Bus connection not ready"); - return; + return NM_TERNARY_DEFAULT; } if (!priv->dbus_has_owner) { @@ -344,7 +338,7 @@ send_updates(NMDnsSystemdResolved *self) /* we have no name owner and we already tried poking the service to * autostart. */ _LOGT("send-updates: no name owner"); - return; + return NM_TERNARY_FALSE; } _LOGT("send-updates: no name owner. Try start service..."); @@ -356,9 +350,26 @@ send_updates(NMDnsSystemdResolved *self) NULL, NULL, NULL); + return NM_TERNARY_DEFAULT; + } + + return NM_TERNARY_TRUE; +} + +static void +send_updates(NMDnsSystemdResolved *self) +{ + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); + RequestItem * request_item; + + if (!priv->request_queue_to_send) { + /* nothing to do. */ return; } + if (ensure_resolved_running(self) != NM_TERNARY_TRUE) + return; + nm_clear_g_cancellable(&priv->cancellable); if (c_list_is_empty(&priv->request_queue_lst_head)) { |