From 51d5006ccf2f16ab0cfecf8b8d95f81894850c12 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 2 Apr 2019 20:50:25 -0700 Subject: [PATCH] Detect socket disconnection during protocol selection --- actix-http/CHANGES.md | 2 ++ actix-http/src/service/service.rs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 79187e7a5..e5a162310 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -8,6 +8,8 @@ * Preallocate read buffer for h1 codec +* Detect socket disconnection during protocol selection + ## [0.1.0-alpha.2] - 2019-03-29 diff --git a/actix-http/src/service/service.rs b/actix-http/src/service/service.rs index 0bc1634d8..50a1a6bdf 100644 --- a/actix-http/src/service/service.rs +++ b/actix-http/src/service/service.rs @@ -247,7 +247,10 @@ where loop { unsafe { let b = item.1.bytes_mut(); - let n = { try_ready!(item.0.poll_read(b)) }; + let n = try_ready!(item.0.poll_read(b)); + if n == 0 { + return Ok(Async::Ready(())); + } item.1.advance_mut(n); if item.1.len() >= HTTP2_PREFACE.len() { break;