WIP: aquatic_ws: use microseconds for poll timeout, remove unwrap

This commit is contained in:
Joakim Frostegård 2020-08-01 03:44:29 +02:00
parent a5108f813d
commit 0f072244ab
3 changed files with 8 additions and 6 deletions

View file

@ -48,7 +48,7 @@ pub struct NetworkConfig {
pub tls_pkcs12_path: String, pub tls_pkcs12_path: String,
pub tls_pkcs12_password: String, pub tls_pkcs12_password: String,
pub poll_event_capacity: usize, pub poll_event_capacity: usize,
pub poll_timeout_milliseconds: u64, pub poll_timeout_microseconds: u64,
pub websocket_max_message_size: usize, pub websocket_max_message_size: usize,
pub websocket_max_frame_size: usize, pub websocket_max_frame_size: usize,
} }
@ -124,7 +124,7 @@ impl Default for NetworkConfig {
tls_pkcs12_path: "".into(), tls_pkcs12_path: "".into(),
tls_pkcs12_password: "".into(), tls_pkcs12_password: "".into(),
poll_event_capacity: 4096, poll_event_capacity: 4096,
poll_timeout_milliseconds: 50, poll_timeout_microseconds: 1000,
websocket_max_message_size: 64 * 1024, websocket_max_message_size: 64 * 1024,
websocket_max_frame_size: 16 * 1024, websocket_max_frame_size: 16 * 1024,
} }

View file

@ -260,11 +260,13 @@ impl Connection {
pub fn close(&mut self){ pub fn close(&mut self){
if let Either::Left(ref mut ews) = self.inner { if let Either::Left(ref mut ews) = self.inner {
if ews.ws.can_read(){ if ews.ws.can_read(){
ews.ws.close(None).unwrap(); if let Err(err) = ews.ws.close(None){
::log::error!("error closing ws: {}", err);
}
// Required after ws.close() // Required after ws.close()
if let Err(err) = ews.ws.write_pending(){ if let Err(err) = ews.ws.write_pending(){
info!( ::log::info!(
"error writing pending messages after closing ws: {}", "error writing pending messages after closing ws: {}",
err err
) )

View file

@ -60,8 +60,8 @@ pub fn run_poll_loop(
listener: ::std::net::TcpListener, listener: ::std::net::TcpListener,
opt_tls_acceptor: Option<TlsAcceptor>, opt_tls_acceptor: Option<TlsAcceptor>,
){ ){
let poll_timeout = Duration::from_millis( let poll_timeout = Duration::from_micros(
config.network.poll_timeout_milliseconds config.network.poll_timeout_microseconds
); );
let ws_config = WebSocketConfig { let ws_config = WebSocketConfig {
max_message_size: Some(config.network.websocket_max_message_size), max_message_size: Some(config.network.websocket_max_message_size),