Handle ErrorKind::Interrupted when waiting for events
ErrorKind::Interrupted (libc::EINTR) errors should not break the HttpServer requests loop, they are internally consumed and reported as no events rather than requests errors. Signed-off-by: Adrian Catangiu <acatan@amazon.com>
This commit is contained in:
committed by
Adrian Catangiu
parent
c9ffb90aeb
commit
c33861a13b
@@ -1 +1 @@
|
|||||||
{"coverage_score": 92.8, "exclude_path": "", "crate_features": ""}
|
{"coverage_score": 92.4, "exclude_path": "", "crate_features": ""}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
extern crate epoll;
|
extern crate epoll;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@@ -301,8 +302,11 @@ impl HttpServer {
|
|||||||
// current thread until at least one event is received.
|
// current thread until at least one event is received.
|
||||||
// The received notifications will then populate the `events` array with
|
// The received notifications will then populate the `events` array with
|
||||||
// `event_count` elements, where 1 <= event_count <= MAX_CONNECTIONS.
|
// `event_count` elements, where 1 <= event_count <= MAX_CONNECTIONS.
|
||||||
let event_count =
|
let event_count = match epoll::wait(self.epoll_fd, -1, &mut events[..]) {
|
||||||
epoll::wait(self.epoll_fd, -1, &mut events[..]).map_err(ServerError::IOError)?;
|
Ok(event_count) => event_count,
|
||||||
|
Err(e) if e.kind() == std::io::ErrorKind::Interrupted => 0,
|
||||||
|
Err(e) => return Err(ServerError::IOError(e)),
|
||||||
|
};
|
||||||
// We use `take()` on the iterator over `events` as, even though only
|
// We use `take()` on the iterator over `events` as, even though only
|
||||||
// `events_count` events have been inserted into `events`, the size of
|
// `events_count` events have been inserted into `events`, the size of
|
||||||
// the array is still `MAX_CONNECTIONS`, so we discard empty elements
|
// the array is still `MAX_CONNECTIONS`, so we discard empty elements
|
||||||
|
|||||||
Reference in New Issue
Block a user