Added shutdown event-fd acting as a kill switch actionable from
outside the micro-http server.
Needed to be able to break out of the inner epoll_wait on demand.
This can be used to signal the micro-http server running on a
dedicated thread that it needs to shut down.
Co-authored-by: acatangiu <adrian.catangiu@gmail.com>
Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Additionally, HttpServer::new_from_fd has been marked as unsafe,
since the correctness of the unsafe call within the function
relies on the caller upholding an invariant
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
The stream used by the Connection structure is expected to implement
both Read and Write traits. Since we want the server to be able to
receive file descriptors through control messages mechanism, this patch
extends the expectations regarding the stream by adding ScmSocket to the
list of traits.
Since the stream is a UnixStream structure, and since vmm-sys-util
already provides an ScmSocket implementation for UnixStream, extending
the list of traits is very straightforward.
Relying on the newly added trait, the server now reads incoming bytes
through recv_with_fd() function, which replaces the former call to
read(). This change has no intent of modifying the former behavior from
the read(), which is why the returned Option<File> is ignored for now.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Allow the creation of the http server's socket from an existing
fd. This is done to enable another process to initiate the creation of
a server by preparing the socket so it can immediately be used rather
than polling to connect to the path.
Note, the coverage file change due to what appears to be a rounding
error when calculating coverage.
Signed-off-by: William Douglas <william.douglas@intel.com>
The server in `micro_http` was not explicitly handling the `EPOLLHUP`,
`EPOLLRDHUP` and `EPOLLERR` epoll events. Added new checks that close
a connection that is signaled with these events.
Signed-off-by: George Pisaltu <gpl@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
This commit adds a mechanism that considers
some errors as 'fatal'. It alerts the user and then
terminates the Firecracker process.
Signed-off-by: berciuliviu <lberciu@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
Changed the way we handle TransferEncoding
and added new test cases.
Signed-off-by: cihodar <cihodar@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
In Rust 2018 edition, it is considered unidiomatic to use "extern crate"
sunthax. The proper way to do it is to replace extern crate with "use"
declarations.
- Also impl clippy suggestions for fn main removal in doctests
- Fix unneeded box allocations and clones
Signed-off-by: Damien Stanton <damien.stanton@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
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>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
Move epoll.rs from polly to utils crate and use this file,
in micro_http, as an epoll wrapper instead of the epoll crate.
Signed-off-by: Laura Loghin <lauralg@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
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>
When closing a http connection, the corresponding file descriptor
should be unregistered from the epoll fd.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Pulled the code from firecracker-microvm/src/micro-http.
Signed-off-by: George Pisaltu <gpl@amazon.com>
Signed-off-by: Andreea Florescu <fandree@amazon.com>