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>
This commit is contained in:
Kevin O'Connor 2017-03-24 19:16:33 -04:00
parent f28eb902df
commit 6de85d02ae
1 changed files with 1 additions and 1 deletions

View File

@ -496,7 +496,7 @@ handle_message(struct serialqueue *sq, double eventtime, int len)
// Add message to receive queue // Add message to receive queue
struct queue_message *qm = message_fill(sq->input_buf, len); struct queue_message *qm = message_fill(sq->input_buf, len);
qm->sent_time = sq->last_receive_sent_time; 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); list_add_tail(&qm->node, &sq->receive_queue);
check_wake_receive(sq); check_wake_receive(sq);
} }