reactor: Use the system monotonic clock instead of the normal system clock
The normal system clock can have sudden jumps if the system clock is changed. Use the system monotonic clock to avoid these sudden changes in time. It appears the Raspbian OS (which is used by OctoPi) is setup to update the system clock upon network connectivity. This could cause sudden system clock changes which could lead to Klippy processing errors. Using the monotonic clock eliminates these issues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include <termios.h> // tcflush
|
||||
#include <unistd.h> // pipe
|
||||
#include "list.h" // list_add_tail
|
||||
#include "pyhelper.h" // get_time
|
||||
#include "pyhelper.h" // get_monotonic
|
||||
#include "serialqueue.h" // struct queue_message
|
||||
|
||||
|
||||
@@ -149,11 +149,11 @@ static void
|
||||
pollreactor_run(struct pollreactor *pr)
|
||||
{
|
||||
pr->must_exit = 0;
|
||||
double eventtime = get_time();
|
||||
double eventtime = get_monotonic();
|
||||
while (! pr->must_exit) {
|
||||
int timeout = pollreactor_check_timers(pr, eventtime);
|
||||
int ret = poll(pr->fds, pr->num_fds, timeout);
|
||||
eventtime = get_time();
|
||||
eventtime = get_monotonic();
|
||||
if (ret > 0) {
|
||||
int i;
|
||||
for (i=0; i<pr->num_fds; i++)
|
||||
|
||||
Reference in New Issue
Block a user