mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_http network: avoid infinite loop case; minor other changes
This commit is contained in:
parent
656efc7d4e
commit
8ebfb1d0ce
2 changed files with 17 additions and 13 deletions
|
|
@ -170,6 +170,8 @@ impl <'a>TlsHandshakeMachine {
|
|||
Stream::TlsStream(stream)
|
||||
);
|
||||
|
||||
::log::debug!("established tcp connection");
|
||||
|
||||
Ok(established)
|
||||
},
|
||||
Err(native_tls::HandshakeError::WouldBlock(handshake)) => {
|
||||
|
|
@ -217,6 +219,8 @@ impl Connection {
|
|||
TlsHandshakeMachine::new(tls_acceptor.clone(), tcp_stream)
|
||||
)
|
||||
} else {
|
||||
::log::debug!("established tcp connection");
|
||||
|
||||
ConnectionInner::Established(
|
||||
EstablishedConnection::new(Stream::TcpStream(tcp_stream))
|
||||
)
|
||||
|
|
@ -259,6 +263,7 @@ impl Connection {
|
|||
}
|
||||
}
|
||||
|
||||
/// Takes ownership since TlsStream needs ownership of TcpStream
|
||||
#[inline]
|
||||
pub fn get_in_progress(self) -> Option<TlsHandshakeMachine> {
|
||||
if let ConnectionInner::InProgress(machine) = self.inner {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ pub fn run_poll_loop(
|
|||
&opt_tls_acceptor,
|
||||
);
|
||||
} else {
|
||||
run_handshakes_and_read_requests(
|
||||
handle_connection_read_event(
|
||||
socket_worker_index,
|
||||
&request_channel_sender,
|
||||
&mut local_responses,
|
||||
|
|
@ -172,7 +172,7 @@ fn accept_new_streams(
|
|||
|
||||
/// On the stream given by poll_token, get TLS up and running if requested,
|
||||
/// then read requests and pass on through channel.
|
||||
pub fn run_handshakes_and_read_requests(
|
||||
pub fn handle_connection_read_event(
|
||||
socket_worker_index: usize,
|
||||
request_channel_sender: &RequestChannelSender,
|
||||
local_responses: &mut Vec<(ConnectionMeta, Response)>,
|
||||
|
|
@ -182,19 +182,18 @@ pub fn run_handshakes_and_read_requests(
|
|||
){
|
||||
loop {
|
||||
// Get connection, updating valid_until
|
||||
let opt_connection = {
|
||||
if let Some(connection) = connections.get_mut(&poll_token) {
|
||||
connection.valid_until = valid_until;
|
||||
|
||||
Some(connection)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
let connection = if let Some(c) = connections.get_mut(&poll_token){
|
||||
c
|
||||
} else {
|
||||
// If there is no connection, there is no stream, so there
|
||||
// shouldn't be any (relevant) poll events. In other words, it's
|
||||
// safe to return here
|
||||
return
|
||||
};
|
||||
|
||||
if let Some(established) = opt_connection
|
||||
.and_then(Connection::get_established)
|
||||
{
|
||||
connection.valid_until = valid_until;
|
||||
|
||||
if let Some(established) = connection.get_established(){
|
||||
match established.read_request(){
|
||||
Ok(request) => {
|
||||
let meta = ConnectionMeta {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue