summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-03-27 19:02:15 +0200
committerThomas Haller <thaller@redhat.com>2018-03-29 11:24:32 +0200
commitfe9e18b515a99a227ae90ec12670f5b1e19933b6 (patch)
treecc7c4802374fe204fd38203e6be61188d3fecf5f
parent8e7977c63be734b12ef52afd5d8d225391b95a08 (diff)
downloadNetworkManager-fe9e18b515a99a227ae90ec12670f5b1e19933b6.tar.gz
checkpoint: rework timeout tracking for checkpoints
Instead of scheduling one timeout only, let each checkpoint instance individually schedule a timeout. This has some overhead, but glib is supposed to make scheduling many timers efficient. Otherwise, glib should be fixed. This simplifies in my opinion the code, because it's up to each checkpoint to maintain it's own timeout.
-rw-r--r--src/nm-checkpoint-manager.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/nm-checkpoint-manager.c b/src/nm-checkpoint-manager.c
index c43c8f0fbd..c200545c82 100644
--- a/src/nm-checkpoint-manager.c
+++ b/src/nm-checkpoint-manager.c
@@ -82,11 +82,20 @@ destroy_checkpoint (NMCheckpointManager *self, NMCheckpoint *checkpoint)
g_object_unref (checkpoint);
}
+static GVariant *
+rollback_checkpoint (NMCheckpointManager *self, NMCheckpoint *checkpoint)
+{
+ GVariant *result;
+
+ result = nm_checkpoint_rollback (checkpoint);
+ destroy_checkpoint (self, checkpoint);
+ return result;
+}
+
static gboolean
rollback_timeout_cb (NMCheckpointManager *self)
{
NMCheckpoint *checkpoint, *checkpoint_safe;
- GVariant *result;
gint64 ts, now;
self->rollback_timeout_id = 0;
@@ -96,10 +105,9 @@ rollback_timeout_cb (NMCheckpointManager *self)
c_list_for_each_entry_safe (checkpoint, checkpoint_safe, &self->checkpoints_lst_head, checkpoints_lst) {
ts = nm_checkpoint_get_rollback_ts (checkpoint);
if (ts && ts <= now) {
- result = nm_checkpoint_rollback (checkpoint);
- if (result)
- g_variant_unref (result);
- destroy_checkpoint (self, checkpoint);
+ gs_unref_variant GVariant *result = NULL;
+
+ result = rollback_checkpoint (self, checkpoint);
}
}
@@ -282,8 +290,7 @@ nm_checkpoint_manager_rollback (NMCheckpointManager *self,
return FALSE;
}
- *results = nm_checkpoint_rollback (checkpoint);
- destroy_checkpoint (self, checkpoint);
+ *results = rollback_checkpoint (self, checkpoint);
return TRUE;
}