Work around posix violation in qnx (missing pselect())
Change-Id: I7c1ae85ee7e92da3f394b488643613894977556e Reviewed-by: Peter Hartmann <phartmann@rim.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Bernd Weimer <bweimer@rim.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
6bd03762d4
commit
36f64ec6ac
@ -90,7 +90,14 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
|
|||||||
// loop and recalculate the timeout as needed
|
// loop and recalculate the timeout as needed
|
||||||
int ret;
|
int ret;
|
||||||
forever {
|
forever {
|
||||||
|
#ifndef Q_OS_QNX
|
||||||
ret = ::pselect(nfds, fdread, fdwrite, fdexcept, &timeout, 0);
|
ret = ::pselect(nfds, fdread, fdwrite, fdexcept, &timeout, 0);
|
||||||
|
#else
|
||||||
|
timeval timeoutVal;
|
||||||
|
timeoutVal.tv_sec = timeout.tv_sec;
|
||||||
|
timeoutVal.tv_usec = timeout.tv_nsec / 1000;
|
||||||
|
ret = ::select(nfds, fdread, fdwrite, fdexcept, &timeoutVal);
|
||||||
|
#endif
|
||||||
if (ret != -1 || errno != EINTR)
|
if (ret != -1 || errno != EINTR)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -271,13 +271,13 @@ void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier *notif
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int timevalToMillisecs(const timeval &tv)
|
static inline int timespecToMillisecs(const timespec &tv)
|
||||||
{
|
{
|
||||||
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
return (tv.tv_sec * 1000) + (tv.tv_nsec / 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||||
timeval *timeout)
|
timespec *timeout)
|
||||||
{
|
{
|
||||||
Q_UNUSED(nfds);
|
Q_UNUSED(nfds);
|
||||||
Q_D(QEventDispatcherBlackberry);
|
Q_D(QEventDispatcherBlackberry);
|
||||||
@ -306,9 +306,9 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef
|
|||||||
// Convert timeout to milliseconds
|
// Convert timeout to milliseconds
|
||||||
int timeoutTotal = -1;
|
int timeoutTotal = -1;
|
||||||
if (timeout)
|
if (timeout)
|
||||||
timeoutTotal = timevalToMillisecs(*timeout);
|
timeoutTotal = timespecToMillisecs(*timeout);
|
||||||
int timeoutLeft = timeoutTotal;
|
int timeoutLeft = timeoutTotal;
|
||||||
timeval startTime = qt_gettime();
|
timespec startTime = qt_gettime();
|
||||||
|
|
||||||
// This loop exists such that we can drain the bps event queue of all native events
|
// This loop exists such that we can drain the bps event queue of all native events
|
||||||
// more efficiently than if we were to return control to Qt after each event. This
|
// more efficiently than if we were to return control to Qt after each event. This
|
||||||
@ -332,16 +332,16 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef
|
|||||||
// Update the timeout
|
// Update the timeout
|
||||||
// Clock source is monotonic, so we can recalculate how much timeout is left
|
// Clock source is monotonic, so we can recalculate how much timeout is left
|
||||||
if (timeoutTotal != -1) {
|
if (timeoutTotal != -1) {
|
||||||
timeval t2 = qt_gettime();
|
timespec t2 = qt_gettime();
|
||||||
timeoutLeft = timeoutTotal
|
timeoutLeft = timeoutTotal
|
||||||
- (timevalToMillisecs(t2) - timevalToMillisecs(startTime));
|
- (timespecToMillisecs(t2) - timespecToMillisecs(startTime));
|
||||||
if (timeoutLeft < 0)
|
if (timeoutLeft < 0)
|
||||||
timeoutLeft = 0;
|
timeoutLeft = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeval tnext;
|
timespec tnext;
|
||||||
if (d->timerList.timerWait(tnext)) {
|
if (d->timerList.timerWait(tnext)) {
|
||||||
int timeoutNext = timevalToMillisecs(tnext);
|
int timeoutNext = timespecToMillisecs(tnext);
|
||||||
if (timeoutNext < timeoutLeft || timeoutTotal == -1) {
|
if (timeoutNext < timeoutLeft || timeoutTotal == -1) {
|
||||||
timeoutTotal = timeoutLeft = timeoutNext;
|
timeoutTotal = timeoutLeft = timeoutNext;
|
||||||
startTime = qt_gettime();
|
startTime = qt_gettime();
|
||||||
|
@ -77,7 +77,7 @@ protected:
|
|||||||
QEventDispatcherBlackberry(QEventDispatcherBlackberryPrivate &dd, QObject *parent = 0);
|
QEventDispatcherBlackberry(QEventDispatcherBlackberryPrivate &dd, QObject *parent = 0);
|
||||||
|
|
||||||
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||||
timeval *timeout);
|
timespec *timeout);
|
||||||
int ioEvents(int fd);
|
int ioEvents(int fd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user