summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qeventdispatcher_symbian.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-05-25 08:23:01 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-05-25 08:23:01 (GMT)
commit7c471bde498c07f03acc612d5f132b904bc3870e (patch)
tree136805e93f9b781c6900f5efaa0bd6ce2301b68d /src/corelib/kernel/qeventdispatcher_symbian.cpp
parent55664a0ef4b88b67c9931c7d2f6853e5fa0a9716 (diff)
parent6f6909ac6681ed614f00998a0d43b7b195dbb90b (diff)
downloadQt-7c471bde498c07f03acc612d5f132b904bc3870e.zip
Qt-7c471bde498c07f03acc612d5f132b904bc3870e.tar.gz
Qt-7c471bde498c07f03acc612d5f132b904bc3870e.tar.bz2
Merge remote branch 'origin/4.6' into qt-4.7-from-4.6
Conflicts: demos/spectrum/app/app.pro src/gui/egl/qegl.cpp tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro tests/auto/qmenu/tst_qmenu.cpp
Diffstat (limited to 'src/corelib/kernel/qeventdispatcher_symbian.cpp')
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 33775d2..1cb8455 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -100,25 +100,40 @@ static inline int qt_socket_select(int nfds, fd_set *readfds, fd_set *writefds,
class QSelectMutexGrabber
{
public:
- QSelectMutexGrabber(int fd, QMutex *mutex)
- : m_mutex(mutex)
+ QSelectMutexGrabber(int fd, QMutex *threadMutex, QMutex *selectCallMutex)
+ : m_threadMutex(threadMutex), m_selectCallMutex(selectCallMutex), bHasThreadLock(false)
{
- if (m_mutex->tryLock())
+ // see if selectThread is waiting m_waitCond
+ // if yes ... dont write to pipe
+ if (m_threadMutex->tryLock()) {
+ bHasThreadLock = true;
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_mutex->lock();
+ m_threadMutex->lock();
+ bHasThreadLock = true;
}
~QSelectMutexGrabber()
{
- m_mutex->unlock();
+ if(bHasThreadLock)
+ m_threadMutex->unlock();
}
private:
- QMutex *m_mutex;
+ QMutex *m_threadMutex;
+ QMutex *m_selectCallMutex;
+ bool bHasThreadLock;
};
/*
@@ -400,7 +415,12 @@ void QSelectThread::run()
int ret;
int savedSelectErrno;
- ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0);
+ {
+ // 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);
+ }
savedSelectErrno = errno;
char buffer;
@@ -495,7 +515,9 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta
start();
}
- QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex);
+ QMutexLocker locker(&m_grabberMutex);
+
+ QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex);
Q_ASSERT(!m_AOStatuses.contains(notifier));
@@ -506,7 +528,9 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta
void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier )
{
- QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex);
+ QMutexLocker locker(&m_grabberMutex);
+
+ QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex);
m_AOStatuses.remove(notifier);
@@ -515,7 +539,9 @@ void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier )
void QSelectThread::restart()
{
- QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex);
+ QMutexLocker locker(&m_grabberMutex);
+
+ QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex);
m_waitCond.wakeAll();
}