44 #include <qcoreapplication.h> |
44 #include <qcoreapplication.h> |
45 #include <private/qcoreapplication_p.h> |
45 #include <private/qcoreapplication_p.h> |
46 |
46 |
47 #include <unistd.h> |
47 #include <unistd.h> |
48 #include <errno.h> |
48 #include <errno.h> |
|
49 |
|
50 #include <net/if.h> |
49 |
51 |
50 QT_BEGIN_NAMESPACE |
52 QT_BEGIN_NAMESPACE |
51 |
53 |
52 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS |
54 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS |
53 // when the system UI is Qt based, priority drop is not needed as CPU starved processes will not be killed. |
55 // when the system UI is Qt based, priority drop is not needed as CPU starved processes will not be killed. |
567 } else if(type == QSocketNotifier::Exception && FD_ISSET(i.key()->socket(), fds)) { |
569 } else if(type == QSocketNotifier::Exception && FD_ISSET(i.key()->socket(), fds)) { |
568 /* |
570 /* |
569 * check if socket is in exception set |
571 * check if socket is in exception set |
570 * then signal RequestComplete for it |
572 * then signal RequestComplete for it |
571 */ |
573 */ |
572 qWarning("exception on %d [will close the socket handle - hack]", i.key()->socket()); |
574 qWarning("exception on %d [will do setdefaultif(0) - hack]", i.key()->socket()); |
573 // quick fix; there is a bug |
575 // quick fix; there is a bug |
574 // when doing read on socket |
576 // when doing read on socket |
575 // errors not preoperly mapped |
577 // errors not preoperly mapped |
576 // after offline-ing the device |
578 // after offline-ing the device |
577 // on some devices we do get exception |
579 // on some devices we do get exception |
578 ::close(i.key()->socket()); |
580 // close all exiting sockets |
|
581 // and reset default IAP |
|
582 if(::setdefaultif(0) != KErrNone) // well we can't do much about it |
|
583 qWarning("setdefaultif(0) failed"); |
|
584 |
579 toRemove.append(i.key()); |
585 toRemove.append(i.key()); |
580 TRequestStatus *status = i.value(); |
586 TRequestStatus *status = i.value(); |
581 QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); |
587 QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); |
582 } |
588 } |
583 } |
589 } |
640 { |
646 { |
641 public: |
647 public: |
642 QIdleDetectorThread() |
648 QIdleDetectorThread() |
643 : m_state(STATE_RUN), m_stop(false) |
649 : m_state(STATE_RUN), m_stop(false) |
644 { |
650 { |
645 qt_symbian_throwIfError(m_lock.CreateLocal()); |
651 qt_symbian_throwIfError(m_lock.CreateLocal(0)); |
646 TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, &User::Allocator(), this); |
652 TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, NULL, this); |
647 if (err != KErrNone) |
653 if (err != KErrNone) |
648 m_lock.Close(); |
654 m_lock.Close(); |
649 qt_symbian_throwIfError(err); |
655 qt_symbian_throwIfError(err); |
650 m_idleDetectorThread.SetPriority(EPriorityAbsoluteBackgroundNormal); |
656 m_idleDetectorThread.SetPriority(EPriorityAbsoluteBackgroundNormal); |
651 m_idleDetectorThread.Resume(); |
657 m_idleDetectorThread.Resume(); |
692 |
698 |
693 private: |
699 private: |
694 enum IdleStates {STATE_KICKED, STATE_RUN} m_state; |
700 enum IdleStates {STATE_KICKED, STATE_RUN} m_state; |
695 bool m_stop; |
701 bool m_stop; |
696 RThread m_idleDetectorThread; |
702 RThread m_idleDetectorThread; |
697 RFastLock m_lock; |
703 RSemaphore m_lock; |
698 }; |
704 }; |
699 |
705 |
700 Q_GLOBAL_STATIC(QIdleDetectorThread, idleDetectorThread); |
706 Q_GLOBAL_STATIC(QIdleDetectorThread, idleDetectorThread); |
701 |
707 |
702 const int maxBusyTime = 2000; // maximum time we allow idle detector to be blocked before worrying, in milliseconds |
708 const int maxBusyTime = 2000; // maximum time we allow idle detector to be blocked before worrying, in milliseconds |