mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
quickfix: connection
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
Logger::Logger()
|
||||
{
|
||||
connect(this,&Logger::sigAddToLogger, this, &Logger::handleLog,Qt::QueuedConnection);
|
||||
connect(this,&Logger::sigAddToLogger, this, &Logger::handleLog,Qt::AutoConnection);
|
||||
createDirectory();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ void SendSystem::initialize(DataParser *dataParser,QMutex *globalMutex)
|
||||
|
||||
qDebug() << "SendSystem thread: " << QThread::currentThreadId();
|
||||
mutex = globalMutex;
|
||||
|
||||
}
|
||||
|
||||
void SendSystem::setClient(Client *client,QTcpSocket *socket)
|
||||
@@ -33,12 +32,10 @@ void SendSystem::sendMessageBlock(QString message)
|
||||
|
||||
void SendSystem::sendFileBlock(QString path)
|
||||
{
|
||||
//qDebug() << "sendFileBlock thread: " << QThread::currentThreadId();
|
||||
Logger::instance().log("TRY LOCK MUTEX : " + client->getLogin(),LogLevel::WARNING);
|
||||
QMutexLocker locker(mutex);
|
||||
Logger::instance().log("LOCK MUTEX " + client->getLogin(),LogLevel::WARNING);
|
||||
QFile file(path);
|
||||
QFileInfo fileInfo(file);
|
||||
|
||||
if(file.isOpen()) Logger::instance().log("ALREADY OPEN FILE : " + client->getLogin() + " " + fileInfo.filePath());
|
||||
Logger::instance().log("OPEN FILE : " + client->getLogin() + " " + fileInfo.fileName());
|
||||
|
||||
if(isSendStopped)
|
||||
@@ -84,13 +81,11 @@ void SendSystem::sendFileBlock(QString path)
|
||||
file.close();
|
||||
Logger::instance().log("CLOSE FILE : " + client->getLogin() + " " + fileInfo.fileName());
|
||||
countSend = 0;
|
||||
Logger::instance().log("UNLOCK MUTEX : " + client->getLogin(),LogLevel::WARNING);
|
||||
}
|
||||
|
||||
void SendSystem::sendFileBlockByteArray(QByteArray array, PacketType packetType)
|
||||
{
|
||||
qDebug() << "sendFileBlockByteArray thread: " << QThread::currentThreadId();
|
||||
QMutexLocker locker(mutex);
|
||||
if(client->GETTYPE() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
||||
client->GETTYPE() == TypeClientAutorization::TYPE_GUI)
|
||||
{
|
||||
@@ -129,7 +124,6 @@ void SendSystem::sendVersion()
|
||||
|
||||
void SendSystem::sendFileBlockWithRename(QString path, QString newName)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
qDebug() << "sendFileBlockWithRename thread: " << QThread::currentThreadId();
|
||||
|
||||
QDataStream stream(socket);
|
||||
@@ -201,7 +195,6 @@ void SendSystem::sendDeleteBlock(QString path)
|
||||
|
||||
void SendSystem::sendPacketType(PacketType packetType)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
if (client->GETTYPE() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
||||
client->GETTYPE() == TypeClientAutorization::TYPE_GUI)
|
||||
{
|
||||
@@ -227,7 +220,6 @@ void SendSystem::sendHello()
|
||||
|
||||
void SendSystem::sendNotify(QString notify)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
qDebug() << "SendNotify thread: " << QThread::currentThreadId();
|
||||
auto answer = emit sigSendNotify(notify);//"END");
|
||||
sendXmlAnswer(answer);
|
||||
@@ -235,7 +227,6 @@ void SendSystem::sendNotify(QString notify)
|
||||
|
||||
void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
qDebug() << "SendSystemThread: " << QThread::currentThreadId();
|
||||
if (client->GETTYPE() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
||||
client->GETTYPE() == TypeClientAutorization::TYPE_GUI)
|
||||
@@ -271,6 +262,7 @@ void SendSystem::sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64
|
||||
|
||||
void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> deleteList){
|
||||
|
||||
mutex->lock();
|
||||
QListIterator<FileData> clientIterator(deleteList);
|
||||
|
||||
while(clientIterator.hasNext())
|
||||
@@ -278,7 +270,11 @@ void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> delet
|
||||
FileData data = clientIterator.next();
|
||||
|
||||
sendDeleteBlock(data.path);
|
||||
if(getIsSendStopped()) return;
|
||||
if(getIsSendStopped())
|
||||
{
|
||||
mutex->unlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QListIterator<FileData> serverIterator(fileSendList);
|
||||
@@ -298,12 +294,18 @@ void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> delet
|
||||
socket->waitForBytesWritten();
|
||||
}
|
||||
|
||||
if(isSendStopped) return;
|
||||
if(isSendStopped)
|
||||
{
|
||||
mutex->unlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
emit sigLoadHash();
|
||||
|
||||
sendPacketType(PacketType::TYPE_FINISH);
|
||||
socket->waitForBytesWritten();
|
||||
mutex->unlock();
|
||||
}
|
||||
|
||||
void SendSystem::socketWrite(QByteArray array)
|
||||
|
||||
@@ -59,6 +59,7 @@ private:
|
||||
DataParser* dataParser;
|
||||
quint64 fileSize;
|
||||
QMutex *mutex;
|
||||
QWaitCondition *waitCondition;
|
||||
int countSend;
|
||||
bool isSendStopped;
|
||||
TypeClientAutorization type;
|
||||
|
||||
@@ -40,7 +40,7 @@ void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget,
|
||||
|
||||
connect(this,&ClientHandler::sigSendXmlAnswer,sendSystem,&SendSystem::sendXmlAnswer,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigInitSender,sendSystem,&SendSystem::initialize,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigFileBlock,sendSystem,&SendSystem::sendFileBlock,Qt::QueuedConnection);
|
||||
connect(this,&ClientHandler::sigFileBlock,sendSystem,&SendSystem::sendFileBlock,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigFileBlockByteArray,sendSystem,&SendSystem::sendFileBlockByteArray,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigFolderBlock,sendSystem,&SendSystem::sendFolderBlock,Qt::AutoConnection);
|
||||
connect(this,&ClientHandler::sigGetIsSendStopped,sendSystem,&SendSystem::getIsSendStopped,Qt::AutoConnection);
|
||||
|
||||
Reference in New Issue
Block a user