From 1fe55b2b5527fdd32ca7b8895cb5764f6ac0958f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 6 Nov 2017 08:23:11 -0800 Subject: Don't unwrap accepted connections Helps avoid spurious errors when testing. Closes #277 --- examples/tinyhttp.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples/tinyhttp.rs') 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(); + } } } -- cgit v1.2.3