summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qlockfile_unix.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add support for Apple tvOSMike Krus2016-05-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Pass -xplatform macx-tvos-clang to configure to build. Builds device and simulator by default. Added ‘uikit’ platform with the common setup. Also added QT_PLATFORM_UIKIT define (undocumented). qmake config defines tvos (but not ios). tvOS is 64bits only (QT_ARCH is arm64) and requires bitcode to be embedded in the binary. A new ‘bitcode’ configuration was added. For ReleaseDevice builds (which get archived and push to the store), bitcode is actually embedded (-fembed-bitcode passed to clang). For all other configurations, only using bitcode markers to keep file size down (-fembed-bitcode-marker). Build disables Widgets in qtbase, and qtscript (unsupported, would require fixes to JavaScriptCore source code). Qpa same as on iOS but disables device orientation, status bar, clipboard, menus, dialogs which are not supported on tvOS. Change-Id: I645804fd933be0befddeeb43095a74d2c178b2ba Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-04-271-5/+7
|\ | | | | | | | | | | | | | | Conflicts: src/corelib/io/qprocess_win.cpp src/widgets/itemviews/qheaderview.cpp Change-Id: I0a59ade9cd6e91f770fdf298a7d72a41e79fd761
| * qlockfile_unix - code cleanupTimur Pocheptsov2016-04-221-5/+7
| | | | | | | | | | | | | | | | | | | | Coverity's CID 157687: QCache::insert, indeed, can delete (immediately) the object we're trying to insert. While this never happens actually in qlockfile_unix since we have max cost 10 and insert with cost 1, the code does not look good and Coverity is not happy. Change-Id: I16a428017bf86e151afe5256906e4cab1ef4044a Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-04-131-0/+2
|\| | | | | | | | | | | | | | | | | | | Conflicts: config.tests/unix/compile.test src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java src/testlib/qtestcase.cpp src/testlib/qtestcase.qdoc Change-Id: Ied3c471dbc9a076c8de33d673bd557e88575609d
| * Fix crash when using QLockFile in a global destructorDavid Faure2016-04-101-0/+2
| | | | | | | | | | | | | | | | (for instance any global object which writes out to a config file in the destructor). If the global cache isn't available anymore, don't use it. Change-Id: I851a6e394d0b073aebf3ffd88b1966d424bfb92e Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/devLiang Qi2016-01-261-13/+29
|\ \
| * | Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-01-211-13/+29
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qiodevice_p.h src/corelib/kernel/qvariant_p.h src/corelib/tools/qsimd.cpp src/gui/kernel/qguiapplication.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp Change-Id: I742a093cbb231b282b43e463ec67173e0d29f57a
| | * Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2016-01-191-13/+29
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: config.tests/common/atomic64/atomic64.cpp configure src/3rdparty/forkfd/forkfd.c src/corelib/io/forkfd_qt.cpp src/widgets/kernel/qwidgetwindow.cpp tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tools/configure/configureapp.cpp Change-Id: Ic6168d82e51a0ef1862c3a63bee6722e8f138414
| | | * QLockFile: decide on locking strategy per pathDavid Fries2015-12-111-13/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is filesystem dependent if flock and fcntl locks are independent or the same underlying lock (which causes getting the second lock to fail). A temporary file in /tmp might be on a local file system and pass while the lock file is placed on NFS and fail with: setNativeLocks failed: Resource temporarily unavailable Instead check for lock conflicts per path and cache the result. Change-Id: I39c59bb240cd99ef0a0ec271243770ffd5df8a7d Reviewed-by: David Faure <david.faure@kdab.com>
* | | | Add Intel copyright to files that Intel has had non-trivial contributionThiago Macieira2016-01-211-0/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | I wrote a script to help find the files, but I reviewed the contributions manually to be sure I wasn't claiming copyright for search & replace, adding Q_DECL_NOTHROW or adding "We mean it" headers. Change-Id: I7a9e11d7b64a4cc78e24ffff142b506368fc8842 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>
* | | Haiku: Implement QLockFilePrivate::processNameByPidTobias Koenig2015-12-081-0/+7
| | | | | | | | | | | | | | | Change-Id: Ie9b76d14f901f5aadf7409183165eaccc288effd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | sys/flock.h should not be included for Q_OS_INTEGRITY.Rolland Dudemaine2015-12-041-0/+3
|/ / | | | | | | | | | | | | | | More specifically, equivalent declarations to this BSD header are defined implicitly on INTEGRITY, and the header does not exist. Change-Id: Ib0bd4b22742ef403c83dab0d72c268c1571b8250 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-10-131-2/+4
|\| | | | | | | | | | | | | | | | | Conflicts: src/network/socket/qabstractsocket.cpp src/plugins/platforms/winrt/qwinrtscreen.cpp src/sql/drivers/mysql/qsql_mysql.cpp Change-Id: Ifb73623d09f53340ee5e10283f1f86b580998902
| * QLockFile: fix errno handlingGiuseppe D'Angelo2015-10-121-2/+4
| | | | | | | | | | | | | | | | | | In case of a lock failure, we potentially pollute the errno value before printing it. Also, switch to qt_error_string, as strerror is not reentrant. Change-Id: I952aac14204637155726bcefc0ed8a21d7fcd501 Reviewed-by: David Faure <david.faure@kdab.com>
* | Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-10-021-0/+24
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/doc/src/qmake-manual.qdoc src/corelib/tools/qstring.h src/gui/image/qimagereader.cpp src/network/access/qnetworkaccessmanager.cpp src/tools/qdoc/doc/examples/examples.qdoc src/widgets/accessible/qaccessiblewidgetfactory_p.h src/widgets/doc/qtwidgets.qdocconf Change-Id: I8fae62283aebefe24e5ca4b4abd97386560c0fcb
| * Add QLockFilePrivate::processNameByPid implementation for GNU/kFreeBSDDmitry Shachnev2015-08-271-0/+24
| | | | | | | | | | | | | | | | GLIBC does not provide kinfo_getproc, so we need to call sysctl manually. Change-Id: I3bf22959ff74b3b6c34b5360738e52086a3ff1b4 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | QLockFile: sync to disk to avoid leaving an empty lock file on crashDavid Faure2015-09-281-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | The two lines of code are the same as in QFSFileEnginePrivate::nativeSyncToDisk, but we don't want to create a fileengine instance just for this. qlockfile_win.cpp already calls FlushFileBuffers, only the Unix implementation was missing the equivalent call. Task-number: QTBUG-44771 Change-Id: I2253972857e4de9d27ef442c92983a1088d6f03e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Silence warning about unused parameterThiago Macieira2015-08-101-0/+1
|/ | | | | | | | | | Happened on an iOS build io/qlockfile_unix.cpp:217:51: error: unused parameter 'pid' [-Werror,- Wunused-parameter] Change-Id: Id3d5c7bf4d4c45069621ffff13f7f7a30728c071 Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
* fix build under FreeBSD 10Oswald Buddenhagen2015-06-301-0/+1
| | | | | | | | qlockfile_unix.cpp:236:24: error: use of undeclared identifier 'kinfo_getproc' Task-number: QTBUG-46907 Change-Id: I146b5de99b6149df64c116cbdec81a19e352a3a9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* fix decoding of file paths in QLockFilePrivate::processNameByPidJoerg Bornemann2015-06-121-3/+3
| | | | | | | QFile::decodeName should be used instead of a simple QString::fromUtf8. Change-Id: I76955ab01af55dd373f860f6e3dbffa37e60892c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* fix unterminated char buffer glitchJoerg Bornemann2015-06-121-3/+4
| | | | | | | | | readlink does not append a NUL character to buf. If readlink places PATH_MAX characters into buf, then an unterminated character buffer would have been passed to QString::fromUtf8. Change-Id: Ib1865b8df760fa7da91c3be746dc701a165d93ee Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* take process name into account for QLockFile's pid clash resolutionJoerg Bornemann2015-05-261-0/+48
| | | | | | | | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.4' into merge5.5Allan Sandfeld Jensen2015-05-081-5/+5
|\ | | | | | | | | | | | | | | | | | | | | | | 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-5/+5
| | | | | | | | | | | | | | | | | | [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>
* | Merge remote-tracking branch 'origin/5.4' into 5.5Liang Qi2015-04-151-1/+1
|\| | | | | | | Change-Id: I004854a25ebbf12b1fda88900162fe7878716c58
| * Doc: Fix using Apple-related terminology in Qt CoreAlexander Volkov2015-03-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | Use the name "OS X" instead of "Mac OS X", "Mac OS" and "OSX", and mention iOS. Replace "Carbon Preferences API" by "CFPreferences API" in the QSettings documentation. Change-Id: Ia7f9fb874276c7c445a1649df521b96ff43daa0c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com> Reviewed-by: Topi Reiniö <topi.reinio@digia.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>
* | QLockFile: Avoid zero-sized lock file on write errorhjk2015-03-051-4/+8
| | | | | | | | | | | | | | | | | | | | Failure to write into a successfully opened lock file left the lock file with size 0 in the filesystem. Task-number: QTBUG-44771 Change-Id: I561bf629b9f160174d658bf105be828f71d78ff9 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.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>
* QLockFile: on Windows, retry deleting the lock file if it is being read.David Faure2014-09-111-1/+4
| | | | | | | | | | | | | | | | 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>
* Include unistd.h in the unix implementation source of QLockFileLaszlo Papp2013-10-311-0/+1
| | | | | | | | | | This is necessary to avoid hidden dependencies for int gethostname(char *name, size_t namelen); This was revelead while backporting the class to Qt 4 for QtSerialPort. Change-Id: I1c477d295eeae90b3136fc6aae5d45982d5b1d73 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make the localHostName() copy function return QByteArrayThiago Macieira2013-10-291-8/+8
| | | | | | | | | | This avoids one extra memory allocation when creating the lock file. The number of memory allocations when checking the file are still the same. Change-Id: I16a2fdb7a5458bdc66f8ad1c602582b5698a5b5c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use the fast operator+ (in the form of operator%)Thiago Macieira2013-10-151-7/+4
| | | | | | | | | | QStringBuilder will precalculate the size of the string for us, which avoids extra realloc() and moving data around. Change-Id: I4e31964bb9bfffbe2083b3cb8c120e602160dfd8 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
* Reduce risks of lock file corruptionKevin Ottens2013-10-111-10/+10
| | | | | | | | | | | | Trying to do as few operations as possible once the file got opened. That includes generating the data which will go in the file. Indeed if we crashed at that point the lock file is already emptied. Could happen because of the qAppName call. It's then safer to prepare the data upfront, and just open/write/close if possible. Change-Id: Iad32fa822c6a5958ae89d84a2fe02ed5366ea278 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Fix compilation of QLockFile on SolarisDavid Faure2013-07-161-0/+4
| | | | | | | | flock isn't available but we use fcnlt already (which is the recommended alternative on Solaris) Change-Id: I718e59c4804950a26eeb610888e17ce666522dcc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make qtbase compile with QT_NO_TEMPORARYFILETasuku Suzuki2013-06-041-2/+7
| | | | | | | | Change-Id: Ida2f59bb245ef70bf65f7e8944c4c315d5bc2f81 Reviewed-by: David Faure (KDE) <faure@kde.org> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Long live QLockFileDavid Faure2013-03-051-0/+207
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>