kdecore: use usleep() instead of select() in KLockFile::lock()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-06-23 15:07:22 +03:00
parent 934a74c881
commit 08ce90c113

View file

@ -33,6 +33,7 @@
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <QDateTime>
#include <QFile>
@ -47,9 +48,6 @@
#include "kde_file.h"
#include "kfilesystemtype_p.h"
#include <unistd.h>
#include <fcntl.h>
// Related reading:
// http://www.spinnaker.de/linux/nfs-locking.html
// http://en.wikipedia.org/wiki/File_locking
@ -453,14 +451,7 @@ KLockFile::LockResult KLockFile::lock(LockFlags options)
break;
}
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = n*((KRandom::random() % 200)+100);
if (n < 2000) {
n = n * 2;
}
select(0, 0, 0, 0, &tv);
::usleep((KRandom::random() % 1000) + 200);
}
if (result == LockOK) {
d->isLocked = true;