From e91be71ef04c22e478a3e98256ded87b28d0d767 Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Sun, 22 May 2016 01:32:30 +0200 Subject: Add OpenBSD to list of BSD systems defines using kqueue too Besides FreeBSD and NetBSD, OpenBSD uses kqueue too, so add the according Q_OS_OPENBSD define here to make that work. Patch obtained via OpenBSD qt ports maintainer Vadim Zhukov from OpenBSD qt ports patches. Change-Id: Ib9e6f6303b661beb88666bd3c2bf36a77e929f9d Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemwatcher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 354e4931b9..d8564c4c40 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -52,7 +52,7 @@ # include "qfilesystemwatcher_win_p.h" #elif defined(USE_INOTIFY) # include "qfilesystemwatcher_inotify_p.h" -#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_IOS) +#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_IOS) # include "qfilesystemwatcher_kqueue_p.h" #elif defined(Q_OS_OSX) # include "qfilesystemwatcher_fsevents_p.h" @@ -68,7 +68,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject // there is a chance that inotify may fail on Linux pre-2.6.13 (August // 2005), so we can't just new inotify directly. return QInotifyFileSystemWatcherEngine::create(parent); -#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_IOS) +#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_IOS) return QKqueueFileSystemWatcherEngine::create(parent); #elif defined(Q_OS_OSX) return QFseventsFileSystemWatcherEngine::create(parent); -- cgit v1.2.3 From f8c3820de789a2c08dab2ddb7bf18728cdbd7028 Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Sun, 22 May 2016 15:04:01 +0200 Subject: Compile fix: remove unused variable bool isEmpty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The local variable isEmpty triggers a compile warning with GCC: variable ‘isEmpty’ set but not used [-Werror=unused-but-set-variable], so remove the variable assignment and declaration. Error is triggered on FreeBSD and NetBSD with gcc. Change-Id: I37bdb3408ad69093708f2d4bdb04392da66e04e5 Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemwatcher_kqueue.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp index 80cbcb26cc..9b574cbdfb 100644 --- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp +++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp @@ -166,7 +166,6 @@ QStringList QKqueueFileSystemWatcherEngine::removePaths(const QStringList &paths QStringList *files, QStringList *directories) { - bool isEmpty; QStringList p = paths; if (pathToID.isEmpty()) return p; @@ -187,7 +186,6 @@ QStringList QKqueueFileSystemWatcherEngine::removePaths(const QStringList &paths else files->removeAll(path); } - isEmpty = pathToID.isEmpty(); return p; } -- cgit v1.2.3 From e3d1058ae9de6eee4d64ea1af66571497208d8c5 Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Sun, 22 May 2016 20:15:03 +0200 Subject: Compile fix for NetBSD: only BSD using statvfs, disable f_flags define Compile fix for NetBSD's use of statvfs having f_flags.All other BSDs use statfs instead of statvfs, so the f_flags define needs to be prevented on NetBSD. Fix obtained from Kamil Rytarowski , NetBSD qt ports maintainer. Change-Id: Ifbd7ba0cba7f6cf280f5984c64abd7649f667332 Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 1d1b2907b7..c02d82a711 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -78,7 +78,7 @@ # if !defined(ST_RDONLY) # define ST_RDONLY MNT_RDONLY # endif -# if !defined(_STATFS_F_FLAGS) +# if !defined(_STATFS_F_FLAGS) && !defined(Q_OS_NETBSD) # define _STATFS_F_FLAGS 1 # endif #elif defined(Q_OS_ANDROID) -- cgit v1.2.3 From 261f9101dd8b03019251cf9aa58382de0fbde2e7 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 15 May 2016 14:53:38 +0300 Subject: QLockFile: Use a more robust stale file detection 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 Reviewed-by: Thiago Macieira --- src/corelib/io/qlockfile_win.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp index 5bd1ba04c9..e72e486cce 100644 --- a/src/corelib/io/qlockfile_win.cpp +++ b/src/corelib/io/qlockfile_win.cpp @@ -137,9 +137,11 @@ bool QLockFilePrivate::isApparentlyStale() const if (!procHandle) return true; // We got a handle but check if process is still alive - DWORD dwR = ::WaitForSingleObject(procHandle, 0); + DWORD exitCode = 0; + if (!::GetExitCodeProcess(procHandle, &exitCode)) + exitCode = 0; ::CloseHandle(procHandle); - if (dwR == WAIT_TIMEOUT) + if (exitCode != STILL_ACTIVE) return true; const QString processName = processNameByPid(pid); if (!processName.isEmpty() && processName != appname) -- cgit v1.2.3 From 886086f5d39a317443018689f817e8eb8ecb0be8 Mon Sep 17 00:00:00 2001 From: Aleksei Timofeyev Date: Fri, 22 Apr 2016 12:57:17 +0500 Subject: QWindowsPipeWriter: Discard queued signals in stop() The _q_queueBytesWritten signal may be already queued from the event loop at the time when stop() is called. We do not want to emit signals once stopped, so reset all respective state variables. Change-Id: I343e1702955e0bbc1d11930d19e75dab6e129b4c Reviewed-by: Alex Trotsenko Reviewed-by: Joerg Bornemann --- src/corelib/io/qwindowspipewriter.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index 839dc8a19c..3731aba97b 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -202,6 +202,8 @@ bool QWindowsPipeWriter::write(const QByteArray &ba) void QWindowsPipeWriter::stop() { stopped = true; + bytesWrittenPending = false; + pendingBytesWrittenValue = 0; if (writeSequenceStarted) { if (!qt_cancelIo(handle, &overlapped)) { const DWORD dwError = GetLastError(); -- cgit v1.2.3 From 2f0ffba638bdb868a810bc0349c240b6b6e172cd Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 30 May 2016 14:15:49 +0200 Subject: Fix emission of QProcess:errorOccurred Consistently use setErrorAndEmit to emit errorOccurred and the deprecated error signal. Change-Id: I8bc7634a72d4d13f74bbf76547de08271dfcbb59 Reviewed-by: Kai Koehne --- src/corelib/io/qprocess.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 502628489d..6e1a771258 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -2090,10 +2090,7 @@ void QProcess::start(const QString &program, const QStringList &arguments, OpenM return; } if (program.isEmpty()) { - Q_D(QProcess); - d->processError = QProcess::FailedToStart; - setErrorString(tr("No program defined")); - emit error(d->processError); + d->setErrorAndEmit(QProcess::FailedToStart, tr("No program defined")); return; } @@ -2120,10 +2117,7 @@ void QProcess::start(OpenMode mode) return; } if (d->program.isEmpty()) { - Q_D(QProcess); - d->processError = QProcess::FailedToStart; - setErrorString(tr("No program defined")); - emit error(d->processError); + d->setErrorAndEmit(QProcess::FailedToStart, tr("No program defined")); return; } -- cgit v1.2.3 From 3432742caa5171ceddee0e75adefda9310c3b1eb Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Mon, 23 May 2016 22:00:05 +0200 Subject: Merge BSD implementations of QLockFilePrivate::processNameByPid() Until now, several solutions for the implementations of processNameByPid() on BSD systems existed: - one for FreeBSD using libutil through kinfo_getproc() using sysctl() implicitly - one for GNU/kFreeBSD using sysctl() explicitly added in commit a8f4fa217daa1b6f7b13cc48c1e5ee8d2d76b008 OpenBSD and NetBSD also had different approaches in their ports patches using kvm() and sysctl(). The code unifies this for all BSDs using sysctl(). Change-Id: Iced9ef01e5966d8688f464f51024a7ed562e26a3 Reviewed-by: Thiago Macieira Reviewed-by: Dmitry Shachnev --- src/corelib/io/io.pri | 1 - src/corelib/io/qlockfile_unix.cpp | 43 ++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 8d9908cd90..553c996458 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -147,7 +147,6 @@ win32 { SOURCES += io/qsettings_mac.cpp OBJECTIVE_SOURCES += io/qurl_mac.mm } - freebsd: LIBS_PRIVATE += -lutil # qlockfile_unix.cpp requires this mac { osx { OBJECTIVE_SOURCES += io/qfilesystemwatcher_fsevents.mm diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index f23a232fb8..eed3158fbe 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -59,14 +59,12 @@ # include # include #elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS) +# if !defined(Q_OS_NETBSD) # include -# if defined(__GLIBC__) && defined(__FreeBSD_kernel__) +# endif # include # include # include -# else -# include -# endif #endif QT_BEGIN_NAMESPACE @@ -269,30 +267,33 @@ QString QLockFilePrivate::processNameByPid(qint64 pid) buf[len] = 0; return QFileInfo(QFile::decodeName(buf)).fileName(); #elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS) -# if defined(__GLIBC__) && defined(__FreeBSD_kernel__) - int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }; - size_t len = 0; - if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0) - return QString(); - kinfo_proc *proc = static_cast(malloc(len)); +# if defined(Q_OS_NETBSD) + struct kinfo_proc2 kp; + int mib[6] = { CTL_KERN, KERN_PROC2, KERN_PROC_PID, (int)pid, sizeof(struct kinfo_proc2), 1 }; +# elif defined(Q_OS_OPENBSD) + struct kinfo_proc kp; + int mib[6] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid, sizeof(struct kinfo_proc), 1 }; # else - kinfo_proc *proc = kinfo_getproc(pid); + struct kinfo_proc kp; + int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid }; # endif - if (!proc) + size_t len = sizeof(kp); + u_int mib_len = sizeof(mib)/sizeof(u_int); + + if (sysctl(mib, mib_len, &kp, &len, NULL, 0) < 0) return QString(); -# if defined(__GLIBC__) && defined(__FreeBSD_kernel__) - if (sysctl(mib, 4, proc, &len, NULL, 0) < 0) { - free(proc); + +# if defined(Q_OS_OPENBSD) || defined(Q_OS_NETBSD) + if (kp.p_pid != pid) return QString(); - } - if (proc->ki_pid != pid) { - free(proc); + QString name = QFile::decodeName(kp.p_comm); +# else + if (kp.ki_pid != pid) return QString(); - } + QString name = QFile::decodeName(kp.ki_comm); # endif - QString name = QFile::decodeName(proc->ki_comm); - free(proc); return name; + #else Q_UNUSED(pid); return QString(); -- cgit v1.2.3