mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Avoid crash on stop in ApiServerLocal
It is necessart to wait for QThread to stop before destruction Avoid closing the socket in ApiLocalConnectionHandler destructor as this remained as ultimate cause of crash on stop
This commit is contained in:
parent
c1d8d6a52d
commit
8c21bfcd54
@ -16,21 +16,28 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QStringList>
|
||||
#include <QStringList>
|
||||
#include "ApiServerLocal.h"
|
||||
#include "JsonStream.h"
|
||||
|
||||
namespace resource_api{
|
||||
|
||||
ApiServerLocal::ApiServerLocal(ApiServer* server, const QString &listenPath, QObject *parent) :
|
||||
ApiServerLocal::ApiServerLocal(ApiServer* server,
|
||||
const QString &listenPath, QObject *parent) :
|
||||
QObject(parent), serverThread(this),
|
||||
localListener(server, listenPath) // Must have no parent to be movable to other thread
|
||||
// Must have no parent to be movable to other thread
|
||||
localListener(server, listenPath)
|
||||
{
|
||||
qRegisterMetaType<QAbstractSocket::SocketState>();
|
||||
localListener.moveToThread(&serverThread);
|
||||
serverThread.start();
|
||||
}
|
||||
|
||||
ApiServerLocal::~ApiServerLocal() { serverThread.quit(); }
|
||||
ApiServerLocal::~ApiServerLocal()
|
||||
{
|
||||
serverThread.quit();
|
||||
serverThread.wait();
|
||||
}
|
||||
|
||||
ApiLocalListener::ApiLocalListener(ApiServer *server,
|
||||
const QString &listenPath,
|
||||
@ -62,8 +69,12 @@ ApiLocalConnectionHandler::ApiLocalConnectionHandler(
|
||||
|
||||
ApiLocalConnectionHandler::~ApiLocalConnectionHandler()
|
||||
{
|
||||
mLocalSocket->close();
|
||||
delete mLocalSocket;
|
||||
/* Any attempt of closing the socket here also deferred method call, causes
|
||||
* crash when the core is asked to stop, at least from the JSON API call.
|
||||
* QMetaObject::invokeMethod(&app, "close", Qt::QueuedConnection)
|
||||
* mLocalSocket->disconnectFromServer()
|
||||
* mLocalSocket->close() */
|
||||
mLocalSocket->deleteLater();
|
||||
}
|
||||
|
||||
void ApiLocalConnectionHandler::handlePendingRequests()
|
||||
|
Loading…
Reference in New Issue
Block a user