From 6de85d02ae796c02d63016b3e45da0df396f2adc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 24 Mar 2017 19:16:33 -0400 Subject: [PATCH] serialqueue: Message receive_time must be taken after read() The est_clock calculation code requires timestamps on status messages to never be prior to the reception of the message. The eventtime of handle_message() is taken before the read() and there is a small possibility that it could be inaccurate enough to corrupt the est_clock calculation. Take a new timestamp when storing receive_time to prevent this. This fix prevents some firmware "Move queue empty" shutdowns. Signed-off-by: Kevin O'Connor --- klippy/serialqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/klippy/serialqueue.c b/klippy/serialqueue.c index 4c18c971..cb24d523 100644 --- a/klippy/serialqueue.c +++ b/klippy/serialqueue.c @@ -496,7 +496,7 @@ handle_message(struct serialqueue *sq, double eventtime, int len) // Add message to receive queue struct queue_message *qm = message_fill(sq->input_buf, len); qm->sent_time = sq->last_receive_sent_time; - qm->receive_time = eventtime; + qm->receive_time = get_monotonic(); // must be time post read() list_add_tail(&qm->node, &sq->receive_queue); check_wake_receive(sq); }