Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/corelib/kernel/qeventdispatcher_symbian.cpp

    r651 r769  
    4444#include <qcoreapplication.h>
    4545#include <private/qcoreapplication_p.h>
    46 #include <qdatetime.h>
    4746
    4847#include <unistd.h>
    4948#include <errno.h>
    5049
     50
     51
    5152QT_BEGIN_NAMESPACE
     53
     54
     55
     56
     57
     58
     59
    5260
    5361#define WAKE_UP_PRIORITY CActive::EPriorityStandard
     
    93101{
    94102public:
    95     QSelectMutexGrabber(int fd, QMutex *mutex)
    96         : m_mutex(mutex)
     103    QSelectMutexGrabber(int fd, QMutex *utex)
     104        : m_)
    97105    {
    98         if (m_mutex->tryLock())
     106        // see if selectThread is waiting m_waitCond
     107        // if yes ... dont write to pipe
     108        if (m_threadMutex->tryLock()) {
     109            bHasThreadLock = true;
    99110            return;
     111
     112
     113
     114
     115
     116
     117
     118
    100119
    101120        char dummy = 0;
    102121        qt_pipe_write(fd, &dummy, 1);
    103122
    104         m_mutex->lock();
     123        m_threadMutex->lock();
     124        bHasThreadLock = true;
    105125    }
    106126
    107127    ~QSelectMutexGrabber()
    108128    {
    109         m_mutex->unlock();
     129        if(bHasThreadLock)
     130            m_threadMutex->unlock();
    110131    }
    111132
    112133private:
    113     QMutex *m_mutex;
     134    QMutex *m_threadMutex;
     135    QMutex *m_selectCallMutex;
     136    bool bHasThreadLock;
    114137};
    115138
     
    393416        int ret;
    394417        int savedSelectErrno;
    395         ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0);
     418        {
     419            // helps fighting the race condition between
     420            // selctthread and new socket requests (cancel, restart ...)
     421            QMutexLocker locker(&m_selectCallMutex);
     422            ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0);
     423        }
    396424        savedSelectErrno = errno;
    397425
     
    457485
    458486                // traversed all, so update
     487
    459488                updateActivatedNotifiers(QSocketNotifier::Read, &readfds);
    460489                updateActivatedNotifiers(QSocketNotifier::Write, &writefds);
    461                 updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds);
    462490
    463491                break;
     
    469497            }
    470498        } else {
     499
    471500            updateActivatedNotifiers(QSocketNotifier::Read, &readfds);
    472501            updateActivatedNotifiers(QSocketNotifier::Write, &writefds);
    473             updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds);
    474502        }
    475503
     
    488516    }
    489517
    490     QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex);
     518    QMutexLocker locker(&m_grabberMutex);
     519
     520    QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex, &m_selectCallMutex);
    491521
    492522    Q_ASSERT(!m_AOStatuses.contains(notifier));