1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

multiple file sending race condition fix

This commit is contained in:
apprb 2014-10-30 00:40:09 +09:00
parent 7a6b349e17
commit 63992fc522
No known key found for this signature in database
GPG Key ID: B001911B5B22FB9B
2 changed files with 5 additions and 0 deletions

View File

@ -39,6 +39,7 @@
#include <QList> #include <QList>
#include <QBuffer> #include <QBuffer>
#include <QMessageBox> #include <QMessageBox>
#include <QMutexLocker>
const QString Core::CONFIG_FILE_NAME = "data"; const QString Core::CONFIG_FILE_NAME = "data";
const QString Core::TOX_EXT = ".tox"; const QString Core::TOX_EXT = ".tox";
@ -758,6 +759,8 @@ void Core::sendGroupMessage(int groupId, const QString& message)
void Core::sendFile(int32_t friendId, QString Filename, QString FilePath, long long filesize) void Core::sendFile(int32_t friendId, QString Filename, QString FilePath, long long filesize)
{ {
QMutexLocker mlocker(&fileSendMutex);
QByteArray fileName = Filename.toUtf8(); QByteArray fileName = Filename.toUtf8();
int fileNum = tox_new_file_sender(tox, friendId, filesize, (uint8_t*)fileName.data(), fileName.size()); int fileNum = tox_new_file_sender(tox, friendId, filesize, (uint8_t*)fileName.data(), fileName.size());
if (fileNum == -1) if (fileNum == -1)

View File

@ -19,6 +19,7 @@
#include <cstdint> #include <cstdint>
#include <QObject> #include <QObject>
#include <QMutex>
#include "corestructs.h" #include "corestructs.h"
#include "coreav.h" #include "coreav.h"
@ -253,6 +254,7 @@ private:
int dhtServerId; int dhtServerId;
static QList<ToxFile> fileSendQueue, fileRecvQueue; static QList<ToxFile> fileSendQueue, fileRecvQueue;
static ToxCall calls[]; static ToxCall calls[];
QMutex fileSendMutex;
uint8_t* pwsaltedkeys[PasswordType::ptCounter]; // use the pw's hash as the "pw" uint8_t* pwsaltedkeys[PasswordType::ptCounter]; // use the pw's hash as the "pw"