diff options
| author | Michael Biebl <biebl@debian.org> | 2020-04-11 21:30:33 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2020-04-11 21:30:33 +0200 |
| commit | f914c41532a9e4f2bb44be074466b62e4cac8db3 (patch) | |
| tree | 046e8e7a186afecf299cd80d62fa1c93903dbecf /shared/systemd/src/basic/time-util.c | |
| parent | 19e73abd360f0198f94ce49f36ddf009056f6324 (diff) | |
| parent | 1e5977b62f896e844b548c3007ace9e1dfa7f9ed (diff) | |
Update upstream source from tag 'upstream/1.23.90'
Update to upstream version '1.23.90' with Debian dir 38c3873648b51c73a9e448ccb2ac18152c2b3f85
Diffstat (limited to 'shared/systemd/src/basic/time-util.c')
| -rw-r--r-- | shared/systemd/src/basic/time-util.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/shared/systemd/src/basic/time-util.c b/shared/systemd/src/basic/time-util.c index 4411127a..71af4f21 100644 --- a/shared/systemd/src/basic/time-util.c +++ b/shared/systemd/src/basic/time-util.c @@ -1507,9 +1507,30 @@ int time_change_fd(void) { if (fd < 0) return -errno; - if (timerfd_settime(fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its, NULL) < 0) - return -errno; + if (timerfd_settime(fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its, NULL) >= 0) + return TAKE_FD(fd); + + /* So apparently there are systems where time_t is 64bit, but the kernel actually doesn't support + * 64bit time_t. In that case configuring a timer to TIME_T_MAX will fail with EOPNOTSUPP or a + * similar error. If that's the case let's try with INT32_MAX instead, maybe that works. It's a bit + * of a black magic thing though, but what can we do? + * + * We don't want this code on x86-64, hence let's conditionalize this for systems with 64bit time_t + * but where "long" is shorter than 64bit, i.e. 32bit archs. + * + * See: https://github.com/systemd/systemd/issues/14362 */ + +#if SIZEOF_TIME_T == 8 && ULONG_MAX < UINT64_MAX + if (ERRNO_IS_NOT_SUPPORTED(errno) || errno == EOVERFLOW) { + static const struct itimerspec its32 = { + .it_value.tv_sec = INT32_MAX, + }; + + if (timerfd_settime(fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its32, NULL) >= 0) + return TAKE_FD(fd); + } +#endif - return TAKE_FD(fd); + return -errno; } #endif /* NM_IGNORED */ |