0
0
mirror of https://github.com/signalapp/libsignal.git synced 2024-09-20 03:52:17 +02:00

Quick-fix for the race between auth and unauth ws connectors

This commit is contained in:
moiseev-signal 2024-07-10 14:11:32 -07:00 committed by GitHub
parent 7af57ad1dd
commit 89547673af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -438,14 +438,19 @@ pub fn chat_service<T: TransportConnector + 'static>(
incoming_tx: tokio::sync::mpsc::Sender<ServerEvent<T::Stream>>,
auth: Auth,
) -> Chat<impl ChatServiceWithDebugInfo, impl ChatServiceWithDebugInfo> {
let ws_service_connector = ChatOverWebSocketServiceConnector::new(
// Cannot reuse the same connector, since they lock on `incoming_tx` internally.
let unauth_ws_connector = ChatOverWebSocketServiceConnector::new(
WebSocketClientConnector::new(transport_connector.clone(), endpoint.config.clone()),
incoming_tx.clone(),
);
let auth_ws_connector = ChatOverWebSocketServiceConnector::new(
WebSocketClientConnector::new(transport_connector, endpoint.config.clone()),
incoming_tx,
);
{
let auth_service =
build_authorized_chat_service(&endpoint.manager, &ws_service_connector, auth);
let unauth_service = build_anonymous_chat_service(&endpoint.manager, &ws_service_connector);
build_authorized_chat_service(&endpoint.manager, &auth_ws_connector, auth);
let unauth_service = build_anonymous_chat_service(&endpoint.manager, &unauth_ws_connector);
Chat {
auth_service,
unauth_service,