summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-02-11 09:26:43 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2020-02-11 09:26:43 +0100
commit2e53fd45613cbc45d86f63c9a207dc3cb869698a (patch)
tree2eebb25d47205f4adc6ef53888649cc330f30748
parenta119dac99815f4736cb9b3b11a7732bc4c8b32b0 (diff)
parent45521b1b3872e1f95cb3863f0eae0f8e2408ea42 (diff)
dhcp: merge branch 'bg/nettools-request-free'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/409
-rw-r--r--shared/n-dhcp4/src/n-dhcp4-c-connection.c5
-rw-r--r--src/dhcp/nm-dhcp-nettools.c14
2 files changed, 15 insertions, 4 deletions
diff --git a/shared/n-dhcp4/src/n-dhcp4-c-connection.c b/shared/n-dhcp4/src/n-dhcp4-c-connection.c
index 3dd053567..d4354467d 100644
--- a/shared/n-dhcp4/src/n-dhcp4-c-connection.c
+++ b/shared/n-dhcp4/src/n-dhcp4-c-connection.c
@@ -1104,13 +1104,14 @@ int n_dhcp4_c_connection_start_request(NDhcp4CConnection *connection,
if (request->userdata.start_time == 0)
request->userdata.start_time = timestamp;
- n_dhcp4_outgoing_free(connection->request);
- connection->request = request;
+ connection->request = n_dhcp4_outgoing_free(connection->request);
r = n_dhcp4_c_connection_send_request(connection, request, timestamp);
if (r)
return r;
+ connection->request = request;
+
return 0;
}
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c
index 23bdefabb..d3a995626 100644
--- a/src/dhcp/nm-dhcp-nettools.c
+++ b/src/dhcp/nm-dhcp-nettools.c
@@ -1063,8 +1063,18 @@ dhcp4_event_cb (int fd,
int r;
r = n_dhcp4_client_dispatch (priv->client);
- if (r < 0)
- return G_SOURCE_CONTINUE;
+ if (r < 0) {
+ /* FIXME: if any operation (e.g. send()) fails during the
+ * dispatch, n-dhcp4 returns an error without arming timers
+ * or progressing state, so the only reasonable thing to do
+ * is to move to failed state so that the client will be
+ * restarted. Ideally n-dhcp4 should retry failed operations
+ * a predefined number of times (possibly infinite).
+ */
+ _LOGE ("error %d dispatching events", r);
+ nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
+ return G_SOURCE_REMOVE;
+ }
while (!n_dhcp4_client_pop_event (priv->client, &event) && event) {
dhcp4_event_handle (self, event);