aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-03-24 19:16:33 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-03-24 19:16:33 -0400
commit6de85d02ae796c02d63016b3e45da0df396f2adc (patch)
tree605679f8e9967091545a9218cb9bd3eae0a06ce0 /klippy
parentf28eb902df59472c50af95bde64296b9ba861735 (diff)
downloadkutter-6de85d02ae796c02d63016b3e45da0df396f2adc.tar.gz
kutter-6de85d02ae796c02d63016b3e45da0df396f2adc.tar.xz
kutter-6de85d02ae796c02d63016b3e45da0df396f2adc.zip
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 <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/serialqueue.c2
1 files changed, 1 insertions, 1 deletions
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);
}