]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: move destruction of old time event sources to manager_setup_time_change()
authorLennart Poettering <lennart@poettering.net>
Mon, 28 May 2018 19:32:03 +0000 (21:32 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 6 Jun 2018 08:53:56 +0000 (10:53 +0200)
It's a bit prettier that day as the function won't silently overwrite
any possibly pre-initialized field, and destroy it right before we
allocate a new event source.

src/core/manager.c

index f5664eaa79180a51f316524e55507291f213375a..3a2674ce9384608643438c55135dc202bdcc668e 100644 (file)
@@ -364,6 +364,9 @@ static int manager_setup_time_change(Manager *m) {
         if (m->test_run_flags)
                 return 0;
 
+        m->time_change_event_source = sd_event_source_unref(m->time_change_event_source);
+        m->time_change_fd = safe_close(m->time_change_fd);
+
         /* Uses TFD_TIMER_CANCEL_ON_SET to get notifications whenever
          * CLOCK_REALTIME makes a jump relative to CLOCK_MONOTONIC */
 
@@ -2558,10 +2561,7 @@ static int manager_dispatch_time_change_fd(sd_event_source *source, int fd, uint
                    LOG_MESSAGE("Time has been changed"));
 
         /* Restart the watch */
-        m->time_change_event_source = sd_event_source_unref(m->time_change_event_source);
-        m->time_change_fd = safe_close(m->time_change_fd);
-
-        manager_setup_time_change(m);
+        (void) manager_setup_time_change(m);
 
         HASHMAP_FOREACH(u, m->units, i)
                 if (UNIT_VTABLE(u)->time_change)