[chrony-dev] [PATCH] macOS adjtime() faults with NULL request |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [PATCH] macOS adjtime() faults with NULL request
- From: Bryan Christianson <bryan@xxxxxxxxxxxxx>
- Date: Wed, 9 Aug 2017 05:14:05 +1200
- Cc: Bryan Christianson <bryan@xxxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpcorp.com; s=a1-4; h=Feedback-ID:X-Smtpcorp-Track:Message-Id:Date: Subject:To:From:Reply-To:Sender:List-Unsubscribe; bh=+nOniFSrFtmavifCjZV2iMo8TjgJp+mb+NIe5ArXPLA=; b=iangwvsFmlHTKpuHUFDNTOo+OE XFxzK+LOFAqQjLstH8qlT3FMKReig2Kq7R37ZptIBmci5gEWU0TqwJArZ6IIDgwEcqlkjJEfl+Z7i V/LMQ0pxf3l5/f3P5ncLjifgYdQ1v3LzRGANrXThtQL3PoBwS2cMMcrmHma5hPii88T1/pmmvQOgT ppaNjYODW3bmoaXJlRzsvyq2s0M+VH5wBwmJkt6C1OuRaEkyxmfq1JZoGhn5QlTU1fIxdFdvOHA5F W3EdirsyQpHhlAYpGfFYFlylDHYUAldFLidh5pHegdkrDdpNTs9YdyLzP6dCxuGEbvyoUx29nPoQ7 pghBMBSA==;
- Feedback-id: 149811m:149811acx33YQ:149811s_jvRju_9z:SMTPCORP
On some systems, passing NULL as the first argument to adjtime, will result in returning the amount of adjustment outstanding from a previous call to adjtime().
On macOS this is not allowed and the adjtime call will fault. We can simulate the behaviour of the other systems by cancelling the current adjustment then restarting the adjustment using the outstanding time that was returned. On macOS 10.13 and later, the netbsd driver is now used and must use these semantics when making/measuring corrections.
---
sys_netbsd.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/sys_netbsd.c b/sys_netbsd.c
index ba66b12..226b4eb 100644
--- a/sys_netbsd.c
+++ b/sys_netbsd.c
@@ -84,9 +84,18 @@ get_offset_correction(struct timespec *raw,
{
struct timeval remadj;
double adjustment_remaining;
+#ifdef MACOSX
+ struct timeval t1 = {0, 0};
+ if (PRV_AdjustTime(&t1, &remadj) < 0)
+ LOG_FATAL("adjtime() failed");
+
+ if (PRV_AdjustTime(&remadj, NULL) < 0)
+ LOG_FATAL("adjtime() failed");
+#else
if (PRV_AdjustTime(NULL, &remadj) < 0)
LOG_FATAL("adjtime() failed");
+#endif
adjustment_remaining = UTI_TimevalToDouble(&remadj);
--
2.11.0 (Apple Git-81)
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.