diff options
author | 2017-03-25 20:06:03 +0800 | |
---|---|---|
committer | 2017-03-25 21:51:29 +0800 | |
commit | a7b5b48c96d6b2b6e5653ba4579ef824cf8c4e3d (patch) | |
tree | 44f71d7b278744f9cdfb2a21a991819f70d29af1 /src/protocol/timer.rs | |
parent | Add TimerHandle::dummy(), don't put dummy timers into the wheel (diff) | |
download | wireguard-rs-a7b5b48c96d6b2b6e5653ba4579ef824cf8c4e3d.tar.xz wireguard-rs-a7b5b48c96d6b2b6e5653ba4579ef824cf8c4e3d.zip |
Manage REKEY_AFTER_TIME and REJECT_AFTER_TIME with timers
Diffstat (limited to 'src/protocol/timer.rs')
-rw-r--r-- | src/protocol/timer.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/protocol/timer.rs b/src/protocol/timer.rs index 5b8cf13..3991503 100644 --- a/src/protocol/timer.rs +++ b/src/protocol/timer.rs @@ -28,6 +28,11 @@ type Action = Box<Fn() + Send + Sync>; lazy_static! { /// Global timer controller. pub static ref CONTROLLER: TimerController = TimerController::new(); + static ref DUMMY: ArcTimer = ArcTimer(Arc::new(Timer { + activated: AtomicBool::new(false), + rounds: AtomicUsize::new(0), + action: Box::new(|| {}), + })); } struct Timer { @@ -139,11 +144,7 @@ impl TimerHandle { pub fn dummy() -> Self { TimerHandle { pos: AtomicUsize::new(0), - timer: ArcTimer(Arc::new(Timer { - activated: AtomicBool::new(false), - rounds: AtomicUsize::new(0), - action: Box::new(|| {}), - })), + timer: DUMMY.clone(), } } |