Skip to content

Commit

Permalink
race condition fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chapati committed Aug 9, 2021
1 parent 678ee13 commit a36b8ae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/src/filesystemhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QFileInfo>
#include <QFileInfoList>
#include <QUrl>
#include <QPointer>

#include <qhttpengine/filesystemhandler.h>
#include <qhttpengine/qiodevicecopier.h>
Expand Down Expand Up @@ -88,8 +89,12 @@ void FilesystemHandlerPrivate::processFile(Socket *socket, const QString &absolu
QIODeviceCopier *copier = new QIODeviceCopier(file, socket);
connect(copier, &QIODeviceCopier::finished, copier, &QIODeviceCopier::deleteLater);
connect(copier, &QIODeviceCopier::finished, file, &QFile::deleteLater);
connect(copier, &QIODeviceCopier::finished, [socket]() {
socket->close();

QPointer<Socket> qps = socket;
connect(copier, &QIODeviceCopier::finished, [qps]() {
if(qps) {
qps->close();
}
});

// Stop the copier if the socket is disconnected
Expand Down

0 comments on commit a36b8ae

Please sign in to comment.