Skip to content

Commit

Permalink
Do not monitor writable events for ws server (#2646)
Browse files Browse the repository at this point in the history
* Do not monitor writable events for ws server

* small update
  • Loading branch information
Kailai-Wang committed Apr 10, 2024
1 parent f656039 commit 4a9dd4b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions tee-worker/core/tls-websocket-server/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ where
match tls_session.process_new_packets() {
Ok(_) => {
if tls_session.is_handshaking() {
trace!("TLS session is in handshake");
return ConnectionState::TlsHandshake
}
ConnectionState::Alive
Expand Down
10 changes: 10 additions & 0 deletions tee-worker/core/tls-websocket-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,14 @@ pub(crate) trait WebSocketConnection: Send + Sync {
None => Err(WebSocketError::ConnectionClosed),
}
}

fn deregister(&mut self, poll: &mio::Poll) -> WebSocketResult<()> {
match self.socket() {
Some(s) => {
poll.deregister(s)?;
Ok(())
},
None => Err(WebSocketError::ConnectionClosed),
}
}
}
2 changes: 1 addition & 1 deletion tee-worker/core/tls-websocket-server/src/stream_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<S: Read + Write> MaybeServerTlsStream<S> {

pub fn wants_write(&self) -> bool {
match self {
MaybeServerTlsStream::Plain(_) => true,
MaybeServerTlsStream::Plain(_) => false, // do not monitor writable events for non-tls server
MaybeServerTlsStream::Rustls(s) => s.sess.wants_write(),
}
}
Expand Down
1 change: 1 addition & 0 deletions tee-worker/core/tls-websocket-server/src/ws_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ where

if connection.is_closed() {
trace!("Connection {:?} is closed, removing", token);
connection.deregister(poll)?;
connections_lock.remove(&token);
trace!(
"Closed {:?}, {} active connections remaining",
Expand Down
2 changes: 1 addition & 1 deletion ts-tests/integration-tests/evm-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describeLitentry('Test EVM Module Contract', ``, (context) => {
console.log(`Tx successful with hash: ${createReceipt.transactionHash}`);
};
const setMsg = await setMessage(deployed.contractAddress!, evmAccountRaw, 'Goodbye World');
const sayMsg = await sayMessage(deployed.contractAddress!)
const sayMsg = await sayMessage(deployed.contractAddress!);
const setResult = sayMsg === 'Goodbye World' ? 1 : 0;
assert.equal(1, setResult, 'Contract modified storage query mismatch');

Expand Down

0 comments on commit 4a9dd4b

Please sign in to comment.