fix: prevent daemon ipc client from sending multiple messages at the same time
This commit is contained in:
parent
c6544dd4eb
commit
abfcc59f22
2 changed files with 5 additions and 0 deletions
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <QDebug>
|
||||
#include <QLocalSocket>
|
||||
#include <QMutexLocker>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
|
|
@ -79,6 +80,7 @@ bool DaemonIpcClient::connectToServer()
|
|||
|
||||
void DaemonIpcClient::disconnectFromServer()
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
m_state = State::Disconnecting;
|
||||
qDebug() << "daemon ipc client disconnecting from server";
|
||||
m_socket->disconnectFromServer();
|
||||
|
|
@ -116,6 +118,7 @@ void DaemonIpcClient::handleErrorOccurred()
|
|||
|
||||
bool DaemonIpcClient::sendMessage(const QString &message, const QString &expectAck, const bool expectConnected)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
if (expectConnected && !isConnected()) {
|
||||
qWarning() << "cannot send command, ipc client not connected";
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
||||
class QLocalSocket;
|
||||
|
|
@ -54,6 +55,7 @@ private:
|
|||
|
||||
private:
|
||||
QLocalSocket *m_socket;
|
||||
QMutex m_mutex;
|
||||
State m_state{State::Unconnected};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue