prevent infinte recursion when closing a websocket in case of SSL errors

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>
This commit is contained in:
Matthieu Gallien 2021-09-03 20:01:04 +02:00 committed by Matthieu Gallien (Rebase PR Action)
parent 46f7d07889
commit 95e3ecfd3c

View file

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