summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qlockfile_win.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QtCore/QtNetwork/QTestlib: Fix build with MinGW/g++ 8.1 x64Friedemann Kleint2018-06-251-3/+2
| | | | | | | | | | | | | | Fix warnings about invalid function type casts (return types conflicting with the FARPROC returned by GetProcAddress()) like: corelib\global\qoperatingsystemversion_win.cpp:100:48: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'RtlGetVersionFunction' {aka 'long int (*)(_OSVERSIONINFOW*)'} [-Werror=cast-function-type] io\qlockfile_win.cpp:158:85: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'GetModuleFileNameExFunc' {aka 'long unsigned int (*)(void*, HINSTANCE__*, wchar_t*, long unsigned int)'} [-Werror=cast-function-type] by introducing nested casts. Task-number: QTBUG-68742 Task-number: QTQAINFRA-2095 Change-Id: I3a5d2ea901bf5dc35963c589d61cf3dc7393377a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QLockFile/Unix: save the boot and machine IDs in the lock file tooThiago Macieira2017-11-141-2/+2
| | | | | | | | | | | | | | | 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>
* QLockInfo: Centralize the management of the lock file's contentsThiago Macieira2017-10-061-39/+21
| | | | | | | | | 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-1/+1
| | | | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-06-131-2/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: config_help.txt configure mkspecs/features/uikit/sdk.prf src/corelib/global/qhooks.cpp src/corelib/io/qfilesystemwatcher.cpp src/corelib/io/qlockfile_unix.cpp src/corelib/tools/qalgorithms.h src/gui/kernel/qwindowsysteminterface.h src/gui/text/qtextdocument_p.cpp src/network/access/access.pri src/network/access/qnetworkaccessmanager.cpp src/network/access/qnetworkreplynsurlconnectionimpl.mm src/src.pro src/testlib/qtestcase.cpp src/widgets/kernel/qwidgetbackingstore_p.h src/widgets/styles/qwindowscestyle.cpp src/widgets/styles/qwindowsmobilestyle.cpp tests/auto/corelib/io/qdiriterator/qdiriterator.pro tests/auto/corelib/io/qfileinfo/qfileinfo.pro tests/auto/gui/kernel/qwindow/BLACKLIST tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp tools/configure/configureapp.cpp Change-Id: Ibf7fb9c8cf263a810ade82f821345d0725c57c67
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-06-061-2/+4
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf config.tests/unix/nis/nis.cpp mkspecs/unsupported/freebsd-g++/qplatformdefs.h src/corelib/tools/qdatetime.cpp src/corelib/tools/qsimd.cpp src/corelib/tools/qsimd_p.h src/network/access/access.pri src/network/access/qnetworkreplynsurlconnectionimpl.mm src/network/access/qnetworkreplynsurlconnectionimpl_p.h src/plugins/platforms/cocoa/qnsview.mm src/plugins/printsupport/windows/qwindowsprintdevice.cpp tests/auto/corelib/kernel/qobject/tst_qobject.cpp tests/auto/network/access/qnetworkreply/BLACKLIST tests/auto/widgets/widgets/qopenglwidget/BLACKLIST Change-Id: I4b32055bbf922392ef0264fd403405416fffee57
| | * QLockFile: Use a more robust stale file detectionOrgad Shaneh2016-05-291-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a process that locked a lockfile crashes on Windows, sometimes a new instance of the process fails to lock. Unfortunately, I can't find a way to reproduce the problem consistently, but it happens from time to time with Qt Creator and Qbs. There are several ways to detect a dead process on Windows. Some of them can be found in stackoverflow[1]. The current implementation of stale lock detection is based on the second answer (using WaitForSingleObject), but apparently it doesn't work in 100% of the cases. The most voted answer[2] (using GetProcessExitCode) proves to work also on this case. [1] http://stackoverflow.com/q/1591342/764870 [2] http://stackoverflow.com/a/1591379/764870 Task-number: QTBUG-53392 Change-Id: Ied7bf00985d0f12e833b887a0143f7bdeee3e772 Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | QtBase: use printf-style qWarning/qDebug where possible (II)Marc Mutz2016-05-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The printf-style version of QDebug expands to a lot less code than the std::ostream-style version. Of course, you pay in type safety (but compilers warn about it these days), you cannot stream complex Qt types and streaming QStrings is awkward, but in many cases you actually improve on readability. But the main reason is that something that's not supposed to be executed under normal operation has no business bloating executable code size. This is not an attempt at converting all qWarnings() to printf-style, only the low-hanging fruit. In this second part, replace qWarning() << "" << non-QString with qWarning("..%.", non-QString). QString (and QUrl etc) have special escaping handling when streamed into QDebug, so leave those alone. They also seem to expand to less code than the qPrintable() alternative, so there's no reason to replace them. Saves 2KiB, 3.4KiB, ~750b and ~450b in text size in QtCore, Gui, Network and Widgets, resp., on optimized GCC 5.3 AMD64 builds. Change-Id: Iae6823e543544347e628ca1060d6d51e3b04d3f4 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* | | QtCore: Remove Windows CE.Friedemann Kleint2016-03-301-1/+1
|/ / | | | | | | | | | | | | | | | | Remove QSysInfo::WV_CE_5/6 enumeration values, #ifdef sections for Q_OS_WINCE and wince .pro file clauses in library, examples and tests. Task-number: QTBUG-51673 Change-Id: Ib63463445f3a26e04d018b193e4655030002f5f9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.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>
* Merge remote-tracking branch 'origin/5.4' into 5.5Liang Qi2015-06-011-1/+1
|\ | | | | | | | | | | | | | | Conflicts: qmake/generators/mac/pbuilder_pbx.cpp src/corelib/global/qglobal.h Change-Id: I2c0f7544bf194f2d0f59218fd583c822901487b0
| * Ensure the same behavior on Win as Unix re the host in isApparentlyStaleAndy Shaw2015-05-221-1/+1
| | | | | | | | | | | | | | | | | | When the hostname is empty then it is assumed that the lock file is from the same host as the one running the application. Change-Id: Iba8aefc171a209294371dc2022d93ede3035b242 Reviewed-by: Will Wagner <willw@carallon.com> Reviewed-by: David Faure <david.faure@kdab.com>
* | take process name into account for QLockFile's pid clash resolutionJoerg Bornemann2015-05-261-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | WinRT/Winphone: Fix warnings in qtbaseOliver Wolff2015-05-181-1/+5
| | | | | | | | | | | | Change-Id: I41725bcfeee0124b259e96f1e3a261e30f14350a Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.4' into merge5.5Allan Sandfeld Jensen2015-05-081-11/+11
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.h src/corelib/io/qnoncontiguousbytedevice_p.h src/gui/image/qjpeghandler.cpp src/network/access/qhttpthreaddelegate_p.h tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp tests/auto/widgets/widgets/qmenubar/BLACKLIST Change-Id: I01de8c1c28efcedfd7953d05025f54802dc08ab3
| * QLockFile: fix deadlock when the lock file is corruptedOlivier Goffart2015-04-151-11/+11
| | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QLockFile] Fixed a deadlock when the lock file is corrupted. Task-number: QTBUG-44771 Change-Id: Ic490b09d70ff1cc1733b64949889a73720b2d0f3 Reviewed-by: David Faure <david.faure@kdab.com>
* | Windows: Fix QLockFile hanging when file cannot be created.Friedemann Kleint2015-04-231-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Return QLockFile::PermissionError when file does not exist, preventing the stale file detection logic from triggering. Add Windows-only autotest trying to create a lock file in a system folder guarded with checks for elevated processes and UAC virtualization. Task-number: QTBUG-45631 Change-Id: I1790f8f925660f6bf1df94c2ced901e6ec57cbb0 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
* | QLockFile: use QCoreApplication::applicationName.David Faure2015-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | Unlike qAppName, it doesn't require a QCoreApplication instance, making QLockFile usable in destructors of global statics. This also uses the value passed to setApplicationName if called rather than always argv[0]. Change-Id: I40446aba410db42d7cfe6b4408878faf435246f7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.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>
* 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>
* QLockFile: on Windows, retry deleting the lock file if it is being read.David Faure2014-09-111-1/+11
| | | | | | | | | | | | | | | | A "sharing violation" happens when trying to delete the lock file and another thread/process is reading it at that very moment. Detect the error and try again, up to 10000 times - to avoid an infinite loop if QFile::remove fails for another reason such as a sudden change of permissions preventing us from deleting our own lock file. On Unix the deletion can't fail because of readers, but it doesn't hurt to check the return value there too, to catch other reasons for failures such as a sudden permission change. Task-number: QTBUG-38853 Change-Id: Icf12a74faed4a4916e3427abc09d9c33aa141476 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLockFile/Windows: Determine host name from environment variable COMPUTERNAME.Friedemann Kleint2014-07-231-9/+16
| | | | | | | | Useful when using shared directories. Task-number: QTBUG-39967 Change-Id: I2c082e33133b00306378b6ff58478e94119e6a0e Reviewed-by: David Faure <david.faure@kdab.com>
* Added initial file system support for winrtOliver Wolff2013-10-111-1/+13
| | | | | | | | | | | | | | While some functionality is not available for winphone (QFileSystemEngine::tempPath), some functionality can be fully supported. Other cases like checking for stale processes which is needed by QLockFile cannot be covered that easily as obtaining information about other processes is limited due to sandboxing. Change-Id: I9ea80ae2b421eea1ddfd4c5bc2f4b6f8adaee85f Done-with: Kamil Trzcinski Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
* Long live QLockFileDavid Faure2013-03-051-0/+138
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>