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>
This commit is contained in:
Bernd Weimer 2013-06-25 14:44:12 +02:00 committed by The Qt Project
parent 36e6376755
commit 828c034f1e

View File

@ -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;
}