prevent infinte recursion when closing a websocket in case of SSL errors
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 3 Sep 2021 18:01:04 +0000 (20:01 +0200)
committerMatthieu Gallien (Rebase PR Action) <matthieu_gallien@yahoo.fr>
Tue, 7 Sep 2021 07:09:43 +0000 (07:09 +0000)
the slots connected to the web socket can be called even during close
and lead to infinite calls to close -> error slot -> close -> ...

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/pushnotifications.cpp

index fcae8e985b0487c9abc705372d946136d2c71e05..8febf024dd87ea0f45dcf7efbcf6defeb43358c2 100644 (file)
@@ -76,6 +76,9 @@ void PushNotifications::closeWebSocket()
         _reconnectTimer->stop();
     }
 
+    disconnect(_webSocket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error), this, &PushNotifications::onWebSocketError);
+    disconnect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors);
+
     _webSocket->close();
 }
 
@@ -171,6 +174,8 @@ void PushNotifications::openWebSocket()
     const auto webSocketUrl = capabilities.pushNotificationsWebSocketUrl();
 
     qCInfo(lcPushNotifications) << "Open connection to websocket on" << webSocketUrl << "for account" << _account->url();
+    connect(_webSocket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error), this, &PushNotifications::onWebSocketError);
+    connect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors);
     _webSocket->open(webSocketUrl);
 }