summaryrefslogtreecommitdiffstats
path: root/examples/tinyhttp.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-11-06 08:23:11 -0800
committerAlex Crichton <alex@alexcrichton.com>2017-11-06 08:23:11 -0800
commit1fe55b2b5527fdd32ca7b8895cb5764f6ac0958f (patch)
tree11523c6061e1b86c4fe7172b40494475dc5c7233 /examples/tinyhttp.rs
parent25f30c91c44aaa6adc2530cad8a8bdb9e0b99f90 (diff)
Don't unwrap accepted connections
Helps avoid spurious errors when testing. Closes #277
Diffstat (limited to 'examples/tinyhttp.rs')
-rw-r--r--examples/tinyhttp.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/tinyhttp.rs b/examples/tinyhttp.rs
index 2dd109de..1689a358 100644
--- a/examples/tinyhttp.rs
+++ b/examples/tinyhttp.rs
@@ -59,9 +59,10 @@ fn main() {
}
let mut next = 0;
for socket in listener.incoming() {
- let socket = socket.expect("failed to accept");
- channels[next].unbounded_send(socket).expect("worker thread died");
- next = (next + 1) % channels.len();
+ if let Ok(socket) = socket {
+ channels[next].unbounded_send(socket).expect("worker thread died");
+ next = (next + 1) % channels.len();
+ }
}
}