Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/rtadvd Allow timers to exist but be in...
details: https://anonhg.NetBSD.org/src/rev/2b281ad1f180
branches: trunk
changeset: 318388:2b281ad1f180
user: roy <roy%NetBSD.org@localhost>
date: Fri Apr 20 13:27:45 2018 +0000
description:
Allow timers to exist but be inactive.
This will be used in a future commit.
diffstat:
usr.sbin/rtadvd/timer.c | 15 +++++++++++----
usr.sbin/rtadvd/timer.h | 3 ++-
2 files changed, 13 insertions(+), 5 deletions(-)
diffs (67 lines):
diff -r 7ae85503b198 -r 2b281ad1f180 usr.sbin/rtadvd/timer.c
--- a/usr.sbin/rtadvd/timer.c Fri Apr 20 11:31:54 2018 +0000
+++ b/usr.sbin/rtadvd/timer.c Fri Apr 20 13:27:45 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: timer.c,v 1.15 2018/04/20 10:39:37 roy Exp $ */
+/* $NetBSD: timer.c,v 1.16 2018/04/20 13:27:45 roy Exp $ */
/* $KAME: timer.c,v 1.11 2005/04/14 06:22:35 suz Exp $ */
/*
@@ -36,6 +36,7 @@
#include <limits.h>
#include <unistd.h>
#include <syslog.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <search.h>
@@ -110,6 +111,9 @@
/* upate the next expiration time */
if (timespeccmp(&timer->tm, &tm_max, <))
tm_max = timer->tm;
+
+ /* enable the timer */
+ timer->enabled = true;
}
/*
@@ -128,6 +132,8 @@
tm_max = tm_limit;
TAILQ_FOREACH_SAFE(tm, &ra_timer, next, tmn) {
+ if (!tm->enabled)
+ continue;
if (timespeccmp(&tm->tm, &now, <=)) {
if ((*tm->expire)(tm->expire_data) == NULL)
continue; /* the timer was removed */
@@ -157,9 +163,10 @@
prog_clock_gettime(CLOCK_MONOTONIC, &now);
if (timespeccmp(&timer->tm, &now, <=)) {
- logit(LOG_DEBUG,
- "<%s> a timer must be expired, but not yet",
- __func__);
+ if (timer->enabled)
+ logit(LOG_DEBUG,
+ "<%s> a timer must be expired, but not yet",
+ __func__);
returnval.tv_sec = 0;
returnval.tv_nsec = 0;
}
diff -r 7ae85503b198 -r 2b281ad1f180 usr.sbin/rtadvd/timer.h
--- a/usr.sbin/rtadvd/timer.h Fri Apr 20 11:31:54 2018 +0000
+++ b/usr.sbin/rtadvd/timer.h Fri Apr 20 13:27:45 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: timer.h,v 1.9 2018/04/20 10:39:37 roy Exp $ */
+/* $NetBSD: timer.h,v 1.10 2018/04/20 13:27:45 roy Exp $ */
/* $KAME: timer.h,v 1.5 2002/05/31 13:30:38 jinmei Exp $ */
/*
@@ -35,6 +35,7 @@
TAILQ_ENTRY(rtadvd_timer) next;
struct rainfo *rai;
struct timespec tm;
+ bool enabled;
struct rtadvd_timer *(*expire) (void *); /* expiration function */
void *expire_data;
Home |
Main Index |
Thread Index |
Old Index