Lei YU | e3deb2a | 2019-01-22 17:24:58 +0800 | [diff] [blame] | 1 | From 84a87726eec88e7b11c8aa633bca006a0c0fc435 Mon Sep 17 00:00:00 2001 |
| 2 | From: Yu Watanabe <watanabe.yu+github@gmail.com> |
| 3 | Date: Tue, 15 Jan 2019 02:59:48 +0900 |
| 4 | Subject: [PATCH 1/2] timedate: treat 'activating' or 'inactivating' NTP client |
| 5 | status as 'active' |
| 6 | |
| 7 | When `timedatectl set-time` is called, NTP client may be in |
| 8 | 'activating' or something. For safety, let's treat such states as |
| 9 | 'active'. |
| 10 | |
| 11 | This also changes all unit file status except for 'masked' or 'disabled' |
| 12 | are treated as 'enabled'. |
| 13 | --- |
| 14 | src/timedate/timedated.c | 4 ++-- |
| 15 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 16 | |
| 17 | diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c |
| 18 | index e168889..12308be 100644 |
| 19 | --- a/src/timedate/timedated.c |
| 20 | +++ b/src/timedate/timedated.c |
| 21 | @@ -160,7 +160,7 @@ static int context_ntp_service_is_active(Context *c) { |
| 22 | /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */ |
| 23 | |
| 24 | LIST_FOREACH(units, info, c->units) |
| 25 | - count += streq_ptr(info->active_state, "active"); |
| 26 | + count += !STRPTR_IN_SET(info->active_state, "inactive", "failed"); |
| 27 | |
| 28 | return count; |
| 29 | } |
| 30 | @@ -174,7 +174,7 @@ static int context_ntp_service_is_enabled(Context *c) { |
| 31 | /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */ |
| 32 | |
| 33 | LIST_FOREACH(units, info, c->units) |
| 34 | - count += STRPTR_IN_SET(info->unit_file_state, "enabled", "enabled-runtime"); |
| 35 | + count += !STRPTR_IN_SET(info->unit_file_state, "masked", "masked-runtime", "disabled", "bad"); |
| 36 | |
| 37 | return count; |
| 38 | } |
| 39 | -- |
| 40 | 2.7.4 |
| 41 | |