UI: ControlWorker: Increase max number of allowed args.

This commit is contained in:
Nodir Temirkhodjaev 2021-05-15 11:34:08 +03:00
parent 88db4e5cf8
commit c9f2b8fd9e
2 changed files with 9 additions and 4 deletions

View File

@ -5,7 +5,7 @@
namespace { namespace {
constexpr int commandMaxArgs = 7; constexpr int commandMaxArgs = 16;
constexpr int commandArgMaxSize = 4 * 1024; constexpr int commandArgMaxSize = 4 * 1024;
constexpr quint32 dataMaxSize = 1 * 1024 * 1024; constexpr quint32 dataMaxSize = 1 * 1024 * 1024;
@ -120,8 +120,7 @@ QByteArray ControlWorker::buildCommandData(Control::Command command, const QVari
bool ControlWorker::sendCommandData(const QByteArray &commandData) bool ControlWorker::sendCommandData(const QByteArray &commandData)
{ {
if (commandData.isEmpty()) Q_ASSERT(!commandData.isEmpty());
return false;
const int bytesSent = socket()->write(commandData); const int bytesSent = socket()->write(commandData);
if (bytesSent != commandData.size()) { if (bytesSent != commandData.size()) {
@ -137,6 +136,10 @@ bool ControlWorker::sendCommandData(const QByteArray &commandData)
bool ControlWorker::sendCommand(Control::Command command, const QVariantList &args) bool ControlWorker::sendCommand(Control::Command command, const QVariantList &args)
{ {
const QByteArray buffer = buildCommandData(command, args); const QByteArray buffer = buildCommandData(command, args);
if (buffer.isEmpty()) {
qWarning() << "Bad RPC command to send:" << command << args;
return false;
}
return sendCommandData(buffer); return sendCommandData(buffer);
} }
@ -196,6 +199,8 @@ bool ControlWorker::readRequest()
clearRequest(); clearRequest();
// qDebug() << "requestReady>" << id() << command << args;
emit requestReady(command, args); emit requestReady(command, args);
return true; return true;

View File

@ -211,7 +211,7 @@ void RpcManager::invokeOnClients(Control::Command cmd, const QVariantList &args)
const QByteArray buffer = ControlWorker::buildCommandData(cmd, args); const QByteArray buffer = ControlWorker::buildCommandData(cmd, args);
if (buffer.isEmpty()) { if (buffer.isEmpty()) {
qWarning() << "Bad RPC command:" << cmd << args; qWarning() << "Bad RPC command to invoke:" << cmd << args;
return; return;
} }