summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qlockfile.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QLockFile/Unix: save the boot and machine IDs in the lock file tooThiago Macieira2017-11-141-3/+28
| | | | | | | | | | | | | | | This allows us to make sure that the PID we read is from the same boot as we are right now running. The collision could happen on embedded systems where the boot sequence is fixed, so all the same processes would have the exact same PIDs after reboot as they did before. [ChangeLog][QtCore][QLockFile] QLockFile can now properly conclude that a lock file from a previous boot of the same device is stale and can be removed. This is implemented only for Linux and Apple operating systems. Task-number: QTBUG-63425 Change-Id: I0b48fc8e90304e0dacc3fffd14e8e3a197211788 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QLockFile: don't use QCoreApplication::applicationName()Thiago Macieira2017-10-061-1/+1
| | | | | | | | | | | | | | | | | | | That was stupid for two reasons. First, applicationName() can be changed by the user by calling QCoreApplication::setApplicationName(), so if that happens, we won't be able to properly identify a lock belonging to a given application because the name changed. Second, because applicationName() is not what we compare to. Instead, let's use processNameByPid() on both content creation and verification. [ChangeLog][QtCore][QLockFile] Fixed a bug that would cause QLockFile mis-identify valid lock files as stale if the application name was set with QCoreApplication::setApplicationName(). Change-Id: I0b48fc8e90304e0dacc3fffd14e912a5c98c87e7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QLockInfo: Centralize the management of the lock file's contentsThiago Macieira2017-10-061-10/+61
| | | | | | | | | We duplicated both the creation of the contents and the check if the file was stale. Centralize everything in qlockfile.cpp. Change-Id: I0b48fc8e90304e0dacc3fffd14e91174af79841f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QLockFile: Don't deadlock if the lock file has a mtime in the futureOlivier Goffart2017-03-101-0/+3
| | | | | | | | | | | | Stale Lock files in the future can happen in some situations. For exemple two computers with different clocks access the same file system. It could be that one of the timestamp is totaly off (several years into the future). [ChangeLog][QtCore][QLockFile] Fixed a deadlock occurring if a corrupted lock file's modification time is in the future. Change-Id: I8dac98a0e898c76bcef67f8c195e126c996b6add Reviewed-by: David Faure <david.faure@kdab.com>
* Doc: add a quick note about unfixed Windows encoding bugThiago Macieira2016-12-281-0/+3
| | | | | | Task-number: QTBUG-49640 Change-Id: Icb0289e3118a41dd9438fffd1492925b03de62d6 Reviewed-by: David Faure <david.faure@kdab.com>
* QLockFile::tryLock: prevent over-sleeping in certain casesThiago Macieira2016-08-301-1/+6
| | | | | | | | | | | | | | | The sleep time increases exponentially, but we never checked whether the time to sleep was less than the remaining time. For example, if timeout was 4000 ms on entry, we'd progressively sleep 100 ms, 200, 400, 800, 1600 ms. At this point, the accummulated sleep time would be 3100 ms and the next sleep should be no more than 900 ms. Prior to this change, the tryLock() would then proceed to sleep 3200 ms, for a total wait time of 6300 ms, or 57.5% above the timeout provided by the user. Change-Id: Ifc295639c8cf4ddcaa69fffd146f7586a7ee95e4 Reviewed-by: David Faure <david.faure@kdab.com>
* QLockFile: Use QDeadlineTimer in tryLockThiago Macieira2016-08-301-5/+3
| | | | | | | This simplifies the code a bit. Change-Id: Ifc295639c8cf4ddcaa69fffd146f7535d646cb15 Reviewed-by: David Faure <david.faure@kdab.com>
* QLockFile: move early out earlier to avoid allocations.Anton Kudryavtsev2016-04-251-2/+2
| | | | | | | | Saves reading two lines and allocating storage for them. Change-Id: I71f6c7019f4c097897945eea52851e4623b75dc2 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
* QtCore: replace QStringLiteral with QLatin1String when appendingMarc Mutz2016-02-251-1/+1
| | | | | | | | | | | | | | | | | | It makes little sense to use QStringLiteral for strings which are immediately appended to, or which are appended to other strings, because no dynamic memory allocation is saved by doing so. But if the only advantage of QStringLiteral does not apply, all its disadvantages dominate, to wit: injection of calls to qstring dtor, non-sharability of data between C strings and QStringLiterals and among QStringLiterals, and doubled storage requirements. Fix by replacing QStringLiteral with QLatin1String. Saves 1156B in text size on stripped optimized Linux AMD64 GCC 4.9 builds. Change-Id: If805e431f570ec1d2ac62c548f516f1b17390c3a Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* take process name into account for QLockFile's pid clash resolutionJoerg Bornemann2015-05-261-4/+8
| | | | | | | | | | | | | | | | To cover the situation that the process ID got reused, the current process name is compared to the name of the process that corresponds to the process ID from the lock file. If the process names differ, the lock file is considered stale. [ChangeLog][QtCore][QLockFile] Detection of stale lock files got more robust and takes the name of the process that belongs to the stored PID into account. Task-number: QTBUG-45497 Change-Id: Ic3c0d7e066435451203e77b9b9ce2d70bfb9c570 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: David Faure <david.faure@kdab.com>
* Update copyright headersJani Heikkinen2015-02-111-6/+6
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Allow hostname from lock files to be emptyRainer Keller2014-10-271-1/+1
| | | | | | | | | | | The common format for lock files is to only contain the PID. (See http://www.pathname.com/fhs/2.2/fhs-5.9.html) Qt includes some extra information but we can not expect this information to be present. Otherwise lock files created by other (non-Qt) processes are not handled correctly. Change-Id: Ib9be3c9f07eb8e87193f56d96f5559bbdd5180b8 Reviewed-by: David Faure <david.faure@kdab.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-081-9/+9
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Long live QLockFileDavid Faure2013-03-051-0/+346
Locking between processes, implemented with open(O_EXCL) on Unix and CreateFile(CREATE_NEW) on Windows. Supports detecting stale lock files and deleting them. Advisory locking is used to prevent deletion of files that are still in use. Change-Id: Id00ee2a4e77a29483d869037c7047c59cb909339 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>