summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dns/nm-dns-systemd-resolved.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/dns/nm-dns-systemd-resolved.c b/src/dns/nm-dns-systemd-resolved.c
index de70a60d0f..fe8cd9c2eb 100644
--- a/src/dns/nm-dns-systemd-resolved.c
+++ b/src/dns/nm-dns-systemd-resolved.c
@@ -64,6 +64,7 @@ typedef struct {
bool try_start_blocked:1;
bool dbus_has_owner:1;
bool dbus_initied:1;
+ bool request_queue_to_send:1;
} NMDnsSystemdResolvedPrivate;
struct _NMDnsSystemdResolved {
@@ -132,18 +133,17 @@ call_done (GObject *source, GAsyncResult *r, gpointer user_data)
RequestItem *request_item;
NMLogLevel log_level;
- request_item = user_data;
-
v = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), r, &error);
if (nm_utils_error_is_cancelled (error))
- goto out;
+ return;
+ request_item = user_data;
self = request_item->self;
priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self);
if (v) {
priv->send_updates_warn_ratelimited = FALSE;
- goto out;
+ return;
}
log_level = LOGL_DEBUG;
@@ -158,9 +158,6 @@ call_done (GObject *source, GAsyncResult *r, gpointer user_data)
request_item->operation,
request_item->ifindex,
error->message);
-
-out:
- _request_item_free (request_item);
}
static gboolean
@@ -327,7 +324,7 @@ send_updates (NMDnsSystemdResolved *self)
NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self);
RequestItem *request_item;
- if (c_list_is_empty (&priv->request_queue_lst_head)) {
+ if (!priv->request_queue_to_send) {
/* nothing to do. */
return;
}
@@ -357,16 +354,21 @@ send_updates (NMDnsSystemdResolved *self)
return;
}
- _LOGT ("send-updates: start %lu requests",
- c_list_length (&priv->request_queue_lst_head));
-
nm_clear_g_cancellable (&priv->cancellable);
+ if (c_list_is_empty (&priv->request_queue_lst_head)) {
+ _LOGT ("send-updates: no requests to send");
+ priv->request_queue_to_send = FALSE;
+ return;
+ }
+
+ _LOGT ("send-updates: start %lu requests", c_list_length (&priv->request_queue_lst_head));
+
priv->cancellable = g_cancellable_new ();
- while ((request_item = c_list_first_entry (&priv->request_queue_lst_head,
- RequestItem,
- request_queue_lst))) {
+ priv->request_queue_to_send = FALSE;
+
+ c_list_for_each_entry (request_item, &priv->request_queue_lst_head, request_queue_lst) {
/* Above we explicitly call "StartServiceByName" trying to avoid D-Bus activating systmd-resolved
* multiple times. There is still a race, were we might hit this line although actually
* the service just quit this very moment. In that case, we would try to D-Bus activate the
@@ -387,7 +389,6 @@ send_updates (NMDnsSystemdResolved *self)
priv->cancellable,
call_done,
request_item);
- c_list_unlink (&request_item->request_queue_lst);
}
}
@@ -462,8 +463,8 @@ update (NMDnsPlugin *plugin,
}
}
+ priv->request_queue_to_send = TRUE;
send_updates (self);
-
return TRUE;
}
@@ -483,8 +484,10 @@ name_owner_changed (NMDnsSystemdResolved *self,
_LOGT ("D-Bus name for systemd-resolved has owner %s", owner);
priv->dbus_has_owner = !!owner;
- if (owner)
+ if (owner) {
priv->try_start_blocked = FALSE;
+ priv->request_queue_to_send = TRUE;
+ }
send_updates (self);
}