Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about node_timeout() function? #51

Closed
latelee opened this issue Aug 24, 2016 · 2 comments
Closed

question about node_timeout() function? #51

latelee opened this issue Aug 24, 2016 · 2 comments

Comments

@latelee
Copy link

latelee commented Aug 24, 2016

Hi! I am using & learning horst recently.But I found that the main display window never delete PR after timeout, I enable WIFI on my phone, then disable WIFI when I see it on display window, and wait for 60 sec, my phone mac address is still there.
I dig into the code and found something. It will delete node info using the code:
// node.c node_timeout() if (n->last_seen < (the_time.tv_sec - conf.node_timeout)) { //... }
last_seen is timestamp of the node:
// node.c copy_nodeinfo() n->last_seen = time(NULL);
the_time is current time:
clock_gettime(CLOCK_MONOTONIC, &the_time);
But, the_time.tv_sec is always smaller then n->last_seen, so it will not delete node info.

When I change
clock_gettime(CLOCK_MONOTONIC, &the_time);
to
clock_gettime(CLOCK_REALTIME, &the_time);
everything is OK.

Is there something wrong or just my misunderstanding of horst?
Thanks!

@br101
Copy link
Owner

br101 commented Aug 30, 2016

Yes, this was a bug and it's fixed in the 'stable' branch now. I will make a new 5.1 release once more bugfixes accumulate.

The mistake was to use the time() function instead of monotonic time. Monotonic time is better for dealing with timeouts, since it's unaffected by local time changes (either by NTP or manually).

Thanks for reporting!

@br101 br101 closed this as completed Aug 30, 2016
@latelee
Copy link
Author

latelee commented Aug 31, 2016

Thank you for reply.
I think the following code will need to fix too:
struct tm* ltm = localtime(&the_time.tv_sec);
in write_to_file() of main.c.
because the_time.tv_sec is not the 'real time'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants