diff options
author | Bernd Weimer <bweimer@blackberry.com> | 2013-06-25 14:44:12 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-24 14:51:35 +0200 |
commit | 828c034f1ea54e9abae7d315206dc6993d7b51c4 (patch) | |
tree | d955e27394a4b9fc95bedc60219d3f06a17c194a /src | |
parent | 36e6376755ce0f5dcd022e11d2539f125980a96b (diff) |
BlackBerry: Rearmed socket notifiers after select
Socket notifiers that are registered with BPS are disabled by a call to
select. This solves the echoTest2 test case of QProcess.
Change-Id: Ic7f3f14433477b89eaad5ffbeb6c22a1b5c2e910
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index e9957d2384..bc0ae5a382 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -1031,6 +1031,41 @@ static int qt_timeout_value(int msecs, int elapsed) return timeout < 0 ? 0 : timeout; } +#ifdef Q_OS_BLACKBERRY +// The BlackBerry event dispatcher uses bps_get_event. Unfortunately, already registered +// socket notifiers are disabled by a call to select. This is to rearm the standard streams. +static int bb_select(QProcessPrivate *process, int nfds, fd_set *fdread, fd_set *fdwrite, int timeout) +{ + bool stdoutEnabled = false; + bool stderrEnabled = false; + bool stdinEnabled = false; + + if (process->stdoutChannel.notifier && process->stdoutChannel.notifier->isEnabled()) { + stdoutEnabled = true; + process->stdoutChannel.notifier->setEnabled(false); + } + if (process->stderrChannel.notifier && process->stderrChannel.notifier->isEnabled()) { + stderrEnabled = true; + process->stderrChannel.notifier->setEnabled(false); + } + if (process->stdinChannel.notifier && process->stdinChannel.notifier->isEnabled()) { + stdinEnabled = true; + process->stdinChannel.notifier->setEnabled(false); + } + + const int ret = select_msecs(nfds, fdread, fdwrite, timeout); + + if (stdoutEnabled) + process->stdoutChannel.notifier->setEnabled(true); + if (stderrEnabled) + process->stderrChannel.notifier->setEnabled(true); + if (stdinEnabled) + process->stdinChannel.notifier->setEnabled(true); + + return ret; +} +#endif // Q_OS_BLACKBERRY + bool QProcessPrivate::waitForStarted(int msecs) { Q_Q(QProcess); @@ -1091,7 +1126,11 @@ bool QProcessPrivate::waitForReadyRead(int msecs) add_fd(nfds, stdinChannel.pipe[1], &fdwrite); int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); +#ifdef Q_OS_BLACKBERRY + int ret = bb_select(this, nfds + 1, &fdread, &fdwrite, timeout); +#else int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); +#endif if (ret < 0) { break; } @@ -1163,8 +1202,12 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) if (!writeBuffer.isEmpty() && stdinChannel.pipe[1] != -1) add_fd(nfds, stdinChannel.pipe[1], &fdwrite); - int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); - int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); + int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); +#ifdef Q_OS_BLACKBERRY + int ret = bb_select(this, nfds + 1, &fdread, &fdwrite, timeout); +#else + int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); +#endif if (ret < 0) { break; } @@ -1230,8 +1273,12 @@ bool QProcessPrivate::waitForFinished(int msecs) if (!writeBuffer.isEmpty() && stdinChannel.pipe[1] != -1) add_fd(nfds, stdinChannel.pipe[1], &fdwrite); - int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); - int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); + int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); +#ifdef Q_OS_BLACKBERRY + int ret = bb_select(this, nfds + 1, &fdread, &fdwrite, timeout); +#else + int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); +#endif if (ret < 0) { break; } |