From 906ef94ffd56b7ff2b5e425eac7a5ceb93ec6ad8 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Tue, 21 Mar 2017 20:30:46 -0600
Subject: [PATCH] Fix bug with sleep - wake is not cleared after it occurs Do
 not initialize waitcondition with capacity

---
 src/context/switch.rs      | 1 +
 src/sync/wait_condition.rs | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/context/switch.rs b/src/context/switch.rs
index bbdc8ad4..60cd46ba 100644
--- a/src/context/switch.rs
+++ b/src/context/switch.rs
@@ -45,6 +45,7 @@ pub unsafe fn switch() -> bool {
 
                 let current = arch::time::monotonic();
                 if current.0 > wake.0 || (current.0 == wake.0 && current.1 >= wake.1) {
+                    context.wake = None;
                     context.unblock();
                 }
             }
diff --git a/src/sync/wait_condition.rs b/src/sync/wait_condition.rs
index cb170265..d48af9d6 100644
--- a/src/sync/wait_condition.rs
+++ b/src/sync/wait_condition.rs
@@ -12,7 +12,7 @@ pub struct WaitCondition {
 impl WaitCondition {
     pub fn new() -> WaitCondition {
         WaitCondition {
-            contexts: Mutex::new(Vec::with_capacity(16))
+            contexts: Mutex::new(Vec::new())
         }
     }
 
-- 
GitLab