From 9f7a9b1272357a06cd721d64e66fcde1921bd325 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 24 Jun 2010 10:56:08 +0200 Subject: Updated Harfbuzz from git+ssh://git.freedesktop.org/git/harfbuzz to a80fd59e3b3b18116803a14e6369345933994236 * Disable data structure packing with RVCT, as it appears that the compiler miscompiles the code. --- src/3rdparty/harfbuzz/src/harfbuzz-global.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-global.h b/src/3rdparty/harfbuzz/src/harfbuzz-global.h index 5b2b679..bccd6a2 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-global.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-global.h @@ -39,7 +39,7 @@ #define HB_END_HEADER /* nothing */ #endif -#if defined(__GNUC__) || defined(__ARMCC__) || defined(__CC_ARM) || defined(_MSC_VER) +#if defined(__GNUC__) || defined(_MSC_VER) #define HB_USE_PACKED_STRUCTS #endif -- cgit v0.12 From 06aaa4bc68a1ee10d2a7bb8de4928c92ce84546d Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 24 Jun 2010 11:58:42 +0200 Subject: Revert "Fixing race condition in qeventdispatcher_symbian.cpp code path" This reverts commit 3a9ca8ba50a63e564c15023f65cbac36d365d309. It's the wrong fix for the problem. The socket operations in the select thread are not supposed to be thread safe. It is thread safe between the select thread and the caller thread, but not if there are more than one caller thread. Ensuring complete thread safety would probably require fixes in other areas as well. The correct fix is for the client to ensure that calls to the socket registering functions are either serialized or contained within one thread. Task: QT-3496 RevBy: Aleksandar Sasha Babic --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 101 ++++++++++-------------- src/corelib/kernel/qeventdispatcher_symbian_p.h | 5 -- 2 files changed, 40 insertions(+), 66 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 75b7619..d00a623 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -114,13 +114,9 @@ public: // is in select call if (m_selectCallMutex->tryLock()) { m_selectCallMutex->unlock(); - - //m_threadMutex->lock(); - //bHasThreadLock = true; return; } - char dummy = 0; qt_pipe_write(fd, &dummy, 1); @@ -409,14 +405,11 @@ void QSelectThread::run() FD_ZERO(&exceptionfds); int maxfd = 0; - { - QMutexLocker asoLocker(&m_AOStatusesMutex); - maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Read, &readfds)); - maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Write, &writefds)); - maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Exception, &exceptionfds)); - maxfd = qMax(maxfd, m_pipeEnds[0]); - maxfd++; - } + maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Read, &readfds)); + maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Write, &writefds)); + maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Exception, &exceptionfds)); + maxfd = qMax(maxfd, m_pipeEnds[0]); + maxfd++; FD_SET(m_pipeEnds[0], &readfds); @@ -461,42 +454,40 @@ void QSelectThread::run() FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptionfds); - { - QMutexLocker asoLocker(&m_AOStatusesMutex); - for (QHash::const_iterator i = m_AOStatuses.begin(); - i != m_AOStatuses.end(); ++i) { + for (QHash::const_iterator i = m_AOStatuses.begin(); + i != m_AOStatuses.end(); ++i) { - fd_set onefds; - FD_ZERO(&onefds); - FD_SET(i.key()->socket(), &onefds); + fd_set onefds; + FD_ZERO(&onefds); + FD_SET(i.key()->socket(), &onefds); - fd_set excfds; - FD_ZERO(&excfds); - FD_SET(i.key()->socket(), &excfds); + fd_set excfds; + FD_ZERO(&excfds); + FD_SET(i.key()->socket(), &excfds); - maxfd = i.key()->socket() + 1; + maxfd = i.key()->socket() + 1; - struct timeval timeout; - timeout.tv_sec = 0; - timeout.tv_usec = 0; + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 0; - ret = 0; + ret = 0; - if(i.key()->type() == QSocketNotifier::Read) { - ret = ::select(maxfd, &onefds, 0, &excfds, &timeout); - if(ret != 0) FD_SET(i.key()->socket(), &readfds); - } else if(i.key()->type() == QSocketNotifier::Write) { - ret = ::select(maxfd, 0, &onefds, &excfds, &timeout); - if(ret != 0) FD_SET(i.key()->socket(), &writefds); - } + if(i.key()->type() == QSocketNotifier::Read) { + ret = ::select(maxfd, &onefds, 0, &excfds, &timeout); + if(ret != 0) FD_SET(i.key()->socket(), &readfds); + } else if(i.key()->type() == QSocketNotifier::Write) { + ret = ::select(maxfd, 0, &onefds, &excfds, &timeout); + if(ret != 0) FD_SET(i.key()->socket(), &writefds); + } - } // end for + } // end for + + // traversed all, so update + updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); + updateActivatedNotifiers(QSocketNotifier::Read, &readfds); + updateActivatedNotifiers(QSocketNotifier::Write, &writefds); - // traversed all, so update - updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); - updateActivatedNotifiers(QSocketNotifier::Read, &readfds); - updateActivatedNotifiers(QSocketNotifier::Write, &writefds); - } break; case EINTR: // Should never occur on Symbian, but this is future proof! default: @@ -505,12 +496,9 @@ void QSelectThread::run() break; } } else { - { - QMutexLocker asoLocker(&m_AOStatusesMutex); - updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); - updateActivatedNotifiers(QSocketNotifier::Read, &readfds); - updateActivatedNotifiers(QSocketNotifier::Write, &writefds); - } + updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds); + updateActivatedNotifiers(QSocketNotifier::Read, &readfds); + updateActivatedNotifiers(QSocketNotifier::Write, &writefds); } m_waitCond.wait(&m_mutex); @@ -529,16 +517,12 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta QMutexLocker locker(&m_grabberMutex); - { - // first do the thing - QMutexLocker aosLocker(&m_AOStatusesMutex); - Q_ASSERT(!m_AOStatuses.contains(notifier)); - m_AOStatuses.insert(notifier, status); - } - - // and now tell it to the others QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + Q_ASSERT(!m_AOStatuses.contains(notifier)); + + m_AOStatuses.insert(notifier, status); + m_waitCond.wakeAll(); } @@ -546,15 +530,10 @@ void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) { QMutexLocker locker(&m_grabberMutex); - { - // first do the thing - QMutexLocker aosLocker(&m_AOStatusesMutex); - m_AOStatuses.remove(notifier); - } - - // and now tell it to the others QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + m_AOStatuses.remove(notifier); + m_waitCond.wakeAll(); } diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 68d5833..7021314 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -231,11 +231,6 @@ private: // causes later in locking // of the thread in waitcond QMutex m_selectCallMutex; - - // Argh ... not again - // one more unprotected - // resource is m_AOStatuses - QMutex m_AOStatusesMutex; }; class Q_CORE_EXPORT CQtActiveScheduler : public CActiveScheduler -- cgit v0.12 From 7ae5285132db6c435e91ab097f41097217d68a2c Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 24 Jun 2010 10:57:23 +0200 Subject: Revert "Fixing the race condition in event dispatcher implementation on" This reverts commit 5f21450a61ba2459e6dc5b08b236b15a067bf81f. It's the wrong fix for the problem. The socket operations in the select thread are not supposed to be thread safe. It is thread safe between the select thread and the caller thread, but not if there are more than one caller thread. Ensuring complete thread safety would probably require fixes in other areas as well. The correct fix is for the client to ensure that calls to the socket registering functions are either serialized or contained within one thread. Task: QT-3358 RevBy: Aleksandar Sasha Babic --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 46 ++++++------------------- src/corelib/kernel/qeventdispatcher_symbian_p.h | 20 ----------- 2 files changed, 10 insertions(+), 56 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index d00a623..826caf2 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -100,40 +100,25 @@ static inline int qt_socket_select(int nfds, fd_set *readfds, fd_set *writefds, class QSelectMutexGrabber { public: - QSelectMutexGrabber(int fd, QMutex *threadMutex, QMutex *selectCallMutex) - : m_threadMutex(threadMutex), m_selectCallMutex(selectCallMutex), bHasThreadLock(false) + QSelectMutexGrabber(int fd, QMutex *mutex) + : m_mutex(mutex) { - // see if selectThread is waiting m_waitCond - // if yes ... dont write to pipe - if (m_threadMutex->tryLock()) { - bHasThreadLock = true; + if (m_mutex->tryLock()) return; - } - - // still check that SelectThread - // is in select call - if (m_selectCallMutex->tryLock()) { - m_selectCallMutex->unlock(); - return; - } char dummy = 0; qt_pipe_write(fd, &dummy, 1); - m_threadMutex->lock(); - bHasThreadLock = true; + m_mutex->lock(); } ~QSelectMutexGrabber() { - if(bHasThreadLock) - m_threadMutex->unlock(); + m_mutex->unlock(); } private: - QMutex *m_threadMutex; - QMutex *m_selectCallMutex; - bool bHasThreadLock; + QMutex *m_mutex; }; /* @@ -415,12 +400,7 @@ void QSelectThread::run() int ret; int savedSelectErrno; - { - // helps fighting the race condition between - // selctthread and new socket requests (cancel, restart ...) - QMutexLocker locker(&m_selectCallMutex); - ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0); - } + ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0); savedSelectErrno = errno; char buffer; @@ -515,9 +495,7 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta start(); } - QMutexLocker locker(&m_grabberMutex); - - QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); Q_ASSERT(!m_AOStatuses.contains(notifier)); @@ -528,9 +506,7 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) { - QMutexLocker locker(&m_grabberMutex); - - QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); m_AOStatuses.remove(notifier); @@ -539,9 +515,7 @@ void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier ) void QSelectThread::restart() { - QMutexLocker locker(&m_grabberMutex); - - QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex); + QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex); m_waitCond.wakeAll(); } diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 7021314..8a9c9a0 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -211,26 +211,6 @@ private: QMutex m_mutex; QWaitCondition m_waitCond; bool m_quit; - - // to protect when several - // requests like: - // requestSocketEvents - // cancelSocketEvents - // kick in the same time - // all will fight for m_mutex - // - // TODO: fix more elegantely - // - QMutex m_grabberMutex; - - // this one will tell - // if selectthread is - // really in select call - // and will prevent - // writing to pipe that - // causes later in locking - // of the thread in waitcond - QMutex m_selectCallMutex; }; class Q_CORE_EXPORT CQtActiveScheduler : public CActiveScheduler -- cgit v0.12