- Timestamp:
- Sep 7, 2009, 3:25:07 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/kernel/qeventdispatcher_pm.cpp
r141 r161 497 497 { 498 498 QMutexLocker locker(&mutex); 499 Q_ASSERT(instance); 499 // it is possible that QEventDispatcherPM::unregisterTimers() is called 500 // after detaching the last thread with detachThread() which means all 501 // timers are already removed and the select thread is stopped and deleted. 502 if (!instance) 503 return false; 500 504 501 505 if (instance->timers.isEmpty()) … … 696 700 697 701 do { 698 while (!finish && sockets.isEmpty() && timers.isEmpty()) {699 if (!cancelWait)700 cond.wait(&mutex);701 cancelWait = false;702 }703 704 if (finish)705 break;706 707 702 // process pending socket operations 708 703 while (!pendingSockets.isEmpty()) { … … 733 728 if (maxSockfd == p.sockfd) { 734 729 // find the new hignest socket 735 if (hwnds.isEmpty()) { 736 maxSockfd = -1; 737 } else { 730 maxSockfd = -1; 731 if (!hwnds.isEmpty()) { 738 732 for (Hwnds::const_iterator it = hwnds.constBegin(); 739 733 it != hwnds.constEnd(); ++it) { … … 755 749 int nsel = 0; 756 750 if (maxSockfd >= 0) { 751 757 752 mutex.unlock(); 758 nsel = ::select(maxSockfd + 1, & readS, &writeS, &exS, timeout);753 nsel = ::select(maxSockfd + 1, &, timeout); 759 754 if (nsel > 0) { 760 755 for (Hwnds::const_iterator it = hwnds.constBegin(); … … 764 759 switch (toSockType(it.key())) { 765 760 case QSocketNotifier::Read: 766 isSet = FD_ISSET(sockfd, & readS); break;761 isSet = FD_ISSET(sockfd, &); break; 767 762 case QSocketNotifier::Write: 768 isSet = FD_ISSET(sockfd, & writeS); break;763 isSet = FD_ISSET(sockfd, &); break; 769 764 case QSocketNotifier::Exception: 770 isSet = FD_ISSET(sockfd, & exS); break;765 isSet = FD_ISSET(sockfd, &); break; 771 766 } 772 767 if (isSet) … … 778 773 ulong msecs = timeout ? 779 774 timeout->tv_sec * 1000 + timeout->tv_usec / 1000 : ULONG_MAX; 775 780 776 if (!cancelWait) { 781 if (cond.wait(&mutex, msecs)) 782 nsel = -2; // avoid activation on when cancelled 783 } else { 784 nsel = -2; // same as above 777 if (!cond.wait(&mutex, msecs)) 778 nsel = 0; // indicate timeout 785 779 } 786 780 cancelWait = false; 787 781 } 788 782 789 if (nsel == 0 || (nsel == -1 && errno == EINTR)) {783 if (nsel == 0) { 790 784 // timeout, check if there are expired timers 791 785 activateTimers(); 792 786 } 793 } while(true); 787 788 } while(!finish); 794 789 795 790 mutex.unlock();
Note:
See TracChangeset
for help on using the changeset viewer.