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