| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qeventdispatcher_unix.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||||||||
| QEventDispatcherUNIXPrivatestatic const char *socketType(QSocketNotifier::QEventDispatcherUNIXPrivate()Type type) | ||||||||||||||||||||||||||||||||
| 13 | { | - | ||||||||||||||||||||||||||||||
| 14 | extern Qtswitch (type) { | - | ||||||||||||||||||||||||||||||
| 15 | case never executed: QSocketNotifiercase QSocketNotifier::Read:never executed: ::HANDLE qt_application_thread_idRead:case QSocketNotifier::Read:never executed: case QSocketNotifier::Read: | 0 | ||||||||||||||||||||||||||||||
| 16 | return never executed: "Read"return "Read";never executed: return "Read";never executed: ;return "Read";never executed: return "Read"; | 0 | ||||||||||||||||||||||||||||||
| 17 | mainThread = (QThreadcase never executed: case QSocketNotifier::Write:never executed: QSocketNotifier::currentThreadIdWrite:case QSocketNotifier::Write:never executed: case QSocketNotifier::Write: | 0 | ||||||||||||||||||||||||||||||
| 18 | return never executed: "Write";return "Write";never executed: return "Write"; | 0 | ||||||||||||||||||||||||||||||
| 19 | case never executed: QSocketNotifier::Exception:case QSocketNotifier::Exception:never executed: case QSocketNotifier::Exception: | 0 | ||||||||||||||||||||||||||||||
| 20 | return never executed: "Exception";return "Exception";never executed: return "Exception"; | 0 | ||||||||||||||||||||||||||||||
| 21 | } | - | ||||||||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||||||||
| 23 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()== qt_application_thread_id", "Q_UNREACHABLE was reached",__FILE__,89) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||||||||||||||||||||
| bool pipefail} never executed: end of block | ||||||||||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||||||||
| 26 | QThreadPipe::QThreadPipe() | - | ||||||||||||||||||||||||||||||
| 27 | { | - | ||||||||||||||||||||||||||||||
| 28 | fds[0] = false-1; | - | ||||||||||||||||||||||||||||||
| 29 | thread_pipefds[01] = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);-1; | - | ||||||||||||||||||||||||||||||
| 30 | - | |||||||||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||||||||
| 33 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||||||||
| 35 | QThreadPipe::~QThreadPipe() | - | ||||||||||||||||||||||||||||||
| 36 | { | - | ||||||||||||||||||||||||||||||
| 37 | if (thread_pipefds
| 0 | ||||||||||||||||||||||||||||||
| 38 | close(fds[0]); never executed: close(fds[0]); | 0 | ||||||||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||||||||
| 40 | if (fds[
| 0 | ||||||||||||||||||||||||||||||
| 41 | thread_pipeclose(fds never executed: [1]);close(fds[1]);never executed: close(fds[1]); | 0 | ||||||||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||||||||
| 45 | - | |||||||||||||||||||||||||||||||
| 46 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 47 | bool QThreadPipe::init() | - | ||||||||||||||||||||||||||||||
| 48 | { | - | ||||||||||||||||||||||||||||||
| 49 | if ((
| 0 | ||||||||||||||||||||||||||||||
| 50 | return never executed: truereturn true;never executed: return true;never executed: ;return true;never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||||||||
| 52 | elseif (qt_safe_pipe(thread_pipefds, 04000) == -1
| 0 | ||||||||||||||||||||||||||||||
| 53 | perror("QEventDispatcherUNIXPrivate():"QThreadPipe: Unable to create thread pipe"); | - | ||||||||||||||||||||||||||||||
| 54 | pipefail = truereturn never executed: return false;never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 55 | } | - | ||||||||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||||||||
| 58 | if (pipefail) | 0 | ||||||||||||||||||||||||||||||
| QMessageLogger(__FILE__, 139, __PRETTY_FUNCTION__).fatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe"); | ||||||||||||||||||||||||||||||||
| sn_highest = -1return never executed: return true;never executed: true;return true;never executed: return true; | ||||||||||||||||||||||||||||||||
| 59 | } | - | ||||||||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||||||||
| QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivatepollfd QThreadPipe::prepare() const | ||||||||||||||||||||||||||||||||
| 62 | { | - | ||||||||||||||||||||||||||||||
| 63 | closereturn never executed: return qt_make_pollfd(fds[0], 0x001);never executed: qt_make_pollfd(thread_pipefds[0]);return qt_make_pollfd(fds[0], 0x001);never executed: return qt_make_pollfd(fds[0], 0x001); | 0 | ||||||||||||||||||||||||||||||
| if (thread_pipe[1] != -1) never executed: return qt_make_pollfd(fds[0], 0x001); | ||||||||||||||||||||||||||||||||
| close(thread_pipe[1]); never executed: return qt_make_pollfd(fds[0], 0x001); | ||||||||||||||||||||||||||||||||
| qDeleteAll(timerList never executed: return qt_make_pollfd(fds[0], 0x001);never executed: ], 0x001);return qt_make_pollfd(fds[0], 0x001);never executed: return qt_make_pollfd(fds[0], 0x001); | ||||||||||||||||||||||||||||||||
| 64 | } | - | ||||||||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||||||||
| int QEventDispatcherUNIXPrivate::doSelect(QEventLoopvoid QThreadPipe::ProcessEventsFlags flags, timespec *timeout) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| QEventDispatcherUNIX * const q = q_func(); | ||||||||||||||||||||||||||||||||
| timerList.updateCurrentTime(); | ||||||||||||||||||||||||||||||||
| int nsel; | ||||||||||||||||||||||||||||||||
| dowakeUp() | ||||||||||||||||||||||||||||||||
| 67 | { | - | ||||||||||||||||||||||||||||||
| 68 | int highest = 0;if (!(flags & QEventLoop::ExcludeSocketNotifiers) &&wakeUps.testAndSetAcquire
| 0 | ||||||||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||||||||
| 70 | sn_vec[0].select_fds = sn_vec[0].enabled_fds; | 0 | ||||||||||||||||||||||||||||||
sn_vecif (fds
| ||||||||||||||||||||||||||||||||
sn_vec[2].select_fds
| ||||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | eventfd_t value = sn_vec[2].enabled_fds1; | - | ||||||||||||||||||||||||||||||
| 73 | highest = sn_highestint ret; | - | ||||||||||||||||||||||||||||||
| 74 | } else {do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "ret = D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1"eventfd_write(&((&sn_vecfds[0].select_fds)->fds_bits)[0]) : "memory"], value); } never executed: while (0ret == -1end of block
| 0 | ||||||||||||||||||||||||||||||
| 75 | do { int __d0, __d1; __asm__ __volatile__ ("cld; repreturn never executed: ;return;never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 76 | " "stosq" : "=c" (__d0), "} | - | ||||||||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||||||||
| 78 | char c = D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1"; | - | ||||||||||||||||||||||||||||||
| 79 | qt_safe_write(&((&sn_vecfds[1].select_fds)->fds_bits)[0]) : "memory"], &c, 1); | - | ||||||||||||||||||||||||||||||
| 80 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| while} never executed: end of block | ||||||||||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||||||||
| 83 | int QThreadPipe::check(0); | - | ||||||||||||||||||||||||||||||
| doconst pollfd &pfd) | ||||||||||||||||||||||||||||||||
| 84 | { | - | ||||||||||||||||||||||||||||||
| 85 | int __d0, __d1; __asm__ __volatile__((!(pfd.fd == fds[0])) ? qt_assert("cld; rep; " "stosq" :"pfd.fd "=c" (__d0),== fds[0]"=D" (__d1,__FILE__,192) : "a" (0), "0" (sizeofqt_noop()); | - | ||||||||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||||||||
| 87 | char c[16]; | - | ||||||||||||||||||||||||||||||
| 88 | const int readyread = pfd.revents & 0x001; | - | ||||||||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||||||||
| 90 | if (fd_setreadyread
| 0 | ||||||||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||||||||
| 98 | if (__fd_mask)), "1"fds[1] == -1
| 0 | ||||||||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||||||||
| 100 | eventfd_t value; | - | ||||||||||||||||||||||||||||||
| 101 | eventfd_read(&((&sn_vecfds[2].select_fds)->fds_bits)[0]) : "memory"], &value); | - | ||||||||||||||||||||||||||||||
| 102 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||||||||
| 104 | { | - | ||||||||||||||||||||||||||||||
| 105 | while (::
| 0 | ||||||||||||||||||||||||||||||
}
| ||||||||||||||||||||||||||||||||
int wakeUpFd = initThreadWakeUp();
| ||||||||||||||||||||||||||||||||
highest = qMax(highest
| ||||||||||||||||||||||||||||||||
nsel = q->select
| ||||||||||||||||||||||||||||||||
&sn_vec[
| ||||||||||||||||||||||||||||||||
&sn_vec[1].select_fds,
| ||||||||||||||||||||||||||||||||
&sn_vec[2].select_fds,
| ||||||||||||||||||||||||||||||||
timeout);
never executed: end of block | ||||||||||||||||||||||||||||||||
| 106 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | while (nsel == -1 && ((*__errno_location ()) == 4 || (*__errno_location ()) == 11));if (!wakeUps.testAndSetRelease
| 0 | ||||||||||||||||||||||||||||||
if ((*__errno_location ()) == 9)
| ||||||||||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||||||||
| 111 | fd_set fdset; | - | ||||||||||||||||||||||||||||||
| timeval tm; | ||||||||||||||||||||||||||||||||
| tm.tv_sec = tmQMessageLogger(__FILE__, 218, __PRETTY_FUNCTION__).warning("QThreadPipe: internal error, wakeUps.tv_usec = 0l; | ||||||||||||||||||||||||||||||||
| fortestAndSetRelease(int type =1, 0; type < 3; ++type){ | ||||||||||||||||||||||||||||||||
| QSockNotType::List &list = sn_vec[type].list failed!"); | ||||||||||||||||||||||||||||||||
| 112 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 113 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||||||||
| 115 | return never executed: readyreadreturn readyread;never executed: return readyread;never executed: ;return readyread;never executed: return readyread; | 0 | ||||||||||||||||||||||||||||||
| 116 | } | - | ||||||||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||||||||
| 118 | QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate() | - | ||||||||||||||||||||||||||||||
| 119 | { | - | ||||||||||||||||||||||||||||||
| 120 | if (list__builtin_expect(!!(threadPipe
| 0 | ||||||||||||||||||||||||||||||
continue;
| ||||||||||||||||||||||||||||||||
for
| ||||||||||||||||||||||||||||||||
| 121 | QMessageLogger never executed: QMessageLogger(__FILE__, 228, __PRETTY_FUNCTION__).fatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe");never executed: (int i = 0; i < list.size(); ++i) {QMessageLogger(__FILE__, 228, __PRETTY_FUNCTION__).fatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe");never executed: QMessageLogger(__FILE__, 228, __PRETTY_FUNCTION__).fatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe"); | 0 | ||||||||||||||||||||||||||||||
| QSockNot *sn = list[i]; never executed: QMessageLogger(__FILE__, 228, __PRETTY_FUNCTION__).fatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe"); | ||||||||||||||||||||||||||||||||
| do { int __d0 never executed: QMessageLogger(__FILE__, 228, __PRETTY_FUNCTION__).fatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe");never executed: __FILE__, __d1; __asm__ __volatile__228, __PRETTY_FUNCTION__).fatal("cld; rep; ""QEventDispatcherUNIXPrivate(): "stosq" :Can "=c" (__d0),not "=D" (__d1) :continue "a" (0),without "0" (sizeof (fd_set) / sizeof (__fd_mask)),a "1" (&((&fdset)->fds_bits)[0]) :thread "memory"pipe");QMessageLogger(__FILE__, 228, __PRETTY_FUNCTION__).fatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe");never executed: QMessageLogger(__FILE__, 228, __PRETTY_FUNCTION__).fatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe"); | ||||||||||||||||||||||||||||||||
| 122 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||||||||
| whileQEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate() | ||||||||||||||||||||||||||||||||
| 125 | { | - | ||||||||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||||||||
| 127 | qDeleteAll(0timerList); | - | ||||||||||||||||||||||||||||||
| ((} never executed: end of block | ||||||||||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||||||||
| 130 | void ) (((&fdset)->fds_bits)[((sn->fd) /QEventDispatcherUNIXPrivate::setSocketNotifierPending(8QSocketNotifier *(intnotifier) | - | ||||||||||||||||||||||||||||||
| sizeof{ | ||||||||||||||||||||||||||||||||
| 132 | ((!(notifier)) ? qt_assert(__fd_mask)))] |= ((__fd_mask) 1 << ((sn->fd"notifier",__FILE__,239) % (8 *: qt_noop()); | - | ||||||||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||||||||
| 134 | if (int) sizeofpendingNotifiers.contains
| 0 | ||||||||||||||||||||||||||||||
int ret = -1
| ||||||||||||||||||||||||||||||||
| 135 | return never executed: return;never executed: return;never executed: ;return;never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||||||||
| 137 | dopendingNotifiers << notifier; | - | ||||||||||||||||||||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||||||||
| 140 | int QEventDispatcherUNIXPrivate::activateTimers() | - | ||||||||||||||||||||||||||||||
| 141 | { | - | ||||||||||||||||||||||||||||||
| 142 | switch (type)return never executed: return timerList.activateTimers();never executed: timerList.activateTimers();return timerList.activateTimers();never executed: return timerList.activateTimers(); | 0 | ||||||||||||||||||||||||||||||
| 143 | } | - | ||||||||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||||||||
| 145 | void QEventDispatcherUNIXPrivate::markPendingSocketNotifiers() | - | ||||||||||||||||||||||||||||||
| 146 | { | - | ||||||||||||||||||||||||||||||
| 147 | case 0for (const pollfd &pfd : ret = selectqAsConst(sn->pollfds)) { | - | ||||||||||||||||||||||||||||||
| 148 | if (pfd.
| 0 | ||||||||||||||||||||||||||||||
break
| ||||||||||||||||||||||||||||||||
| 149 | continue never executed: continue;never executed: continue;never executed: ;continue;never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||||||||
| 151 | case 1: | - | ||||||||||||||||||||||||||||||
| retauto it = selectsocketNotifiers.find(sn->pfd.fd+ 1, 0, &fdset); | ||||||||||||||||||||||||||||||||
| 152 | ((!(it != socketNotifiers.end())) ? qt_assert("it != socketNotifiers.end()",0__FILE__,&tm); | - | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| case 2259) : retqt_noop()); | ||||||||||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||||||||
| 154 | const QSocketNotifierSetUNIX &sn_set = select(sn->fd + 1, 0it.value(); | - | ||||||||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||||||||
| 156 | static const struct { | - | ||||||||||||||||||||||||||||||
| 157 | QSocketNotifier::Type type; | - | ||||||||||||||||||||||||||||||
| 158 | short flags; | - | ||||||||||||||||||||||||||||||
| 159 | } notifiers[] = { | - | ||||||||||||||||||||||||||||||
| 160 | { QSocketNotifier::Read, 00x001 | 0x010 | 0x008 }, | - | ||||||||||||||||||||||||||||||
| 161 | { QSocketNotifier::Write, &fdset0x004 | 0x010 | 0x008 }, | - | ||||||||||||||||||||||||||||||
| 162 | { QSocketNotifier::Exception, &tm); | - | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| }0x002 | 0x010 | 0x008 } | ||||||||||||||||||||||||||||||||
| 163 | while (ret == -1 && ((*__errno_location ()) == 4 || (*__errno_location ()) == 11)); | - | ||||||||||||||||||||||||||||||
| if}; | ||||||||||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||||||||
| 165 | for (ret == -1 && (*__errno_location ()) == 9const auto &n : notifiers) { | - | ||||||||||||||||||||||||||||||
| 166 | static const charQSocketNotifier *t[]notifier = sn_set.notifiers[n.type]; | - | ||||||||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||||||||
| 168 | if (!notifier
| 0 | ||||||||||||||||||||||||||||||
| 169 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||||||||
| 171 | if (pfd.revents & 0x020
| 0 | ||||||||||||||||||||||||||||||
| 172 | "Read", "Write", "Exception" };QMessageLogger(__FILE__, 236279, __PRETTY_FUNCTION__).warning("QSocketNotifier: Invalid socket %d andwith type '%s'%s, disabling...", | - | ||||||||||||||||||||||||||||||
| sn->fd, | ||||||||||||||||||||||||||||||||
| 173 | t[it.key(), socketType(n.type]); | - | ||||||||||||||||||||||||||||||
| sn->obj)); | ||||||||||||||||||||||||||||||||
| 174 | notifier->setEnabled(false); | - | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||
| perror("select"); | ||||||||||||||||||||||||||||||||
| 175 | }} never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||||||||
| 177 | int nevents = processThreadWakeUp(nsel);if (! (flags & QEventLoop::ExcludeSocketNotifiers) && nsel > 0 && sn_highest >= 0) { | 0 | ||||||||||||||||||||||||||||||
| for (int i=0; i<3; i++) { | ||||||||||||||||||||||||||||||||
| QSockNotType::List &list = sn_vec[i].list; | ||||||||||||||||||||||||||||||||
for(int j = 0; j < listpfd
| ||||||||||||||||||||||||||||||||
QSockNot *sn = list[j];
| ||||||||||||||||||||||||||||||||
if (((((&sn_vec[i].select_fds)->fds_bits)[((sn->fd) / (8 * (int) sizeof (__fd_mask)))]
| ||||||||||||||||||||||||||||||||
| 178 | sizeof (__fd_mask))))) != 0)) | 0 | ||||||||||||||||||||||||||||||
| q->setSocketNotifierPending(sn->objnotifier); never executed: setSocketNotifierPending(notifier); | ||||||||||||||||||||||||||||||||
| 179 | }} never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 180 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||||||||
| 182 | return (nevents + q->activateSocketNotifiers());pollfds.clear(); | - | ||||||||||||||||||||||||||||||
| 183 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||||||||
| 185 | int QEventDispatcherUNIXPrivate::initThreadWakeUpactivateSocketNotifiers() | - | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| ((void) (((&sn_vec[0].select_fds)->fds_bits)[((thread_pipe[0]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((thread_pipe[0]) % (8 * (int) sizeof (__fd_mask)))))); | ||||||||||||||||||||||||||||||||
| return thread_pipe[0]; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| int QEventDispatcherUNIXPrivate::processThreadWakeUp(int nsel){ | ||||||||||||||||||||||||||||||||
| 187 | markPendingSocketNotifiers(); | - | ||||||||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||||||||
| 189 | if (nsel > 0 && ((((&sn_vec[0].select_fds)->fds_bits)[((thread_pipe[0]) / (8 * (int) sizeof(__fd_mask)))] & ((__fd_mask) 1 << ((thread_pipe[pendingNotifiers.isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 190 | return never executed: return 0;never executed: return 0;never executed: 0]) % (8 * (;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||||||||
| 192 | int ) sizeof (__fd_mask))))) !=n_activated = 0)) { | - | ||||||||||||||||||||||||||||||
| if (thread_pipe[1] == -1) { | ||||||||||||||||||||||||||||||||
| eventfd_t value; | ||||||||||||||||||||||||||||||||
| 193 | eventfd_readQEvent event(thread_pipe[0], &valueQEvent::SockAct); | - | ||||||||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||||||||
| 195 | } else | 0 | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| char c[16];while (::read(thread_pipe[0], c, sizeof(c)) > 0) { | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
if(!wakeUpspendingNotifiers.testAndSetRelease(1, 0))isEmpty()
| ||||||||||||||||||||||||||||||||
| 196 | QMessageLogger(__FILE__, 298, __PRETTY_FUNCTION__).warning("QEventDispatcherUNIX: internal error, wakeUpsQSocketNotifier *notifier = pendingNotifiers.testAndSetReleasetakeFirst(); | - | ||||||||||||||||||||||||||||||
| 197 | QCoreApplication::sendEvent(1notifier, 0) failed!"&event); | - | ||||||||||||||||||||||||||||||
| 198 | } | - | ||||||||||||||||||||||||||||||
| return 1++n_activated; | ||||||||||||||||||||||||||||||||
| 199 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||||||||
| 201 | return never executed: 0n_activated;return n_activated;never executed: return n_activated; | 0 | ||||||||||||||||||||||||||||||
| 202 | } | - | ||||||||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||||||||
| 204 | QEventDispatcherUNIX::QEventDispatcherUNIX(QObject *parent) | - | ||||||||||||||||||||||||||||||
| 205 | : QAbstractEventDispatcher(*new QEventDispatcherUNIXPrivate, parent) | - | ||||||||||||||||||||||||||||||
| 206 | { } | - | ||||||||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||||||||
| 208 | QEventDispatcherUNIX::QEventDispatcherUNIX(QEventDispatcherUNIXPrivate &dd, QObject *parent) | - | ||||||||||||||||||||||||||||||
| 209 | : QAbstractEventDispatcher(dd, parent) | - | ||||||||||||||||||||||||||||||
| 210 | { } | - | ||||||||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||||||||
| 212 | QEventDispatcherUNIX::~QEventDispatcherUNIX() | - | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| int QEventDispatcherUNIX::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, | ||||||||||||||||||||||||||||||||
| timespec *timeout){ return qt_safe_select(nfds, readfds, writefds, exceptfds, timeout);} | ||||||||||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||||||||
| 218 | void QEventDispatcherUNIX::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *obj) | - | ||||||||||||||||||||||||||||||
| 219 | { | - | ||||||||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||||||||
| 221 | if (timerId < 1 || interval < 0 || !obj) { | - | ||||||||||||||||||||||||||||||
| 222 | QMessageLogger(__FILE__, 330329, __PRETTY_FUNCTION__).warning("QEventDispatcherUNIX::registerTimer: invalid arguments"); | - | ||||||||||||||||||||||||||||||
| 223 | return; | - | ||||||||||||||||||||||||||||||
| 224 | } else if (obj->thread() != thread() || thread() != QThread::currentThread()) { | - | ||||||||||||||||||||||||||||||
| 225 | QMessageLogger(__FILE__, 333332, __PRETTY_FUNCTION__).warning("QEventDispatcherUNIX::registerTimer: timers cannot be started from another thread"); | - | ||||||||||||||||||||||||||||||
| 226 | return; | - | ||||||||||||||||||||||||||||||
| 227 | } | - | ||||||||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||||||||
| 230 | QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 231 | d->timerList.registerTimer(timerId, interval, timerType, obj); | - | ||||||||||||||||||||||||||||||
| 232 | } | - | ||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||||||||
| 237 | bool QEventDispatcherUNIX::unregisterTimer(int timerId) | - | ||||||||||||||||||||||||||||||
| 238 | { | - | ||||||||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||||||||
| 240 | if (timerId < 1) { | - | ||||||||||||||||||||||||||||||
| 241 | QMessageLogger(__FILE__, 349348, __PRETTY_FUNCTION__).warning("QEventDispatcherUNIX::unregisterTimer: invalid argument"); | - | ||||||||||||||||||||||||||||||
| 242 | return false; | - | ||||||||||||||||||||||||||||||
| 243 | } else if (thread() != QThread::currentThread()) { | - | ||||||||||||||||||||||||||||||
| 244 | QMessageLogger(__FILE__, 352351, __PRETTY_FUNCTION__).warning("QEventDispatcherUNIX::unregisterTimer: timers cannot be stopped from another thread"); | - | ||||||||||||||||||||||||||||||
| 245 | return false; | - | ||||||||||||||||||||||||||||||
| 246 | } | - | ||||||||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||||||||
| 249 | QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 250 | return d->timerList.unregisterTimer(timerId); | - | ||||||||||||||||||||||||||||||
| 251 | } | - | ||||||||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||||||||
| 253 | - | |||||||||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||||||||
| 256 | bool QEventDispatcherUNIX::unregisterTimers(QObject *object) | - | ||||||||||||||||||||||||||||||
| 257 | { | - | ||||||||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||||||||
| 259 | if (!object) { | - | ||||||||||||||||||||||||||||||
| 260 | QMessageLogger(__FILE__, 368367, __PRETTY_FUNCTION__).warning("QEventDispatcherUNIX::unregisterTimers: invalid argument"); | - | ||||||||||||||||||||||||||||||
| 261 | return false; | - | ||||||||||||||||||||||||||||||
| 262 | } else if (object->thread() != thread() || thread() != QThread::currentThread()) { | - | ||||||||||||||||||||||||||||||
| 263 | QMessageLogger(__FILE__, 371370, __PRETTY_FUNCTION__).warning("QEventDispatcherUNIX::unregisterTimers: timers cannot be stopped from another thread"); | - | ||||||||||||||||||||||||||||||
| 264 | return false; | - | ||||||||||||||||||||||||||||||
| 265 | } | - | ||||||||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||||||||
| 268 | QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 269 | return d->timerList.unregisterTimers(object); | - | ||||||||||||||||||||||||||||||
| 270 | } | - | ||||||||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||||||||
| 272 | QList<QEventDispatcherUNIX::TimerInfo> | - | ||||||||||||||||||||||||||||||
| 273 | QEventDispatcherUNIX::registeredTimers(QObject *object) const | - | ||||||||||||||||||||||||||||||
| 274 | { | - | ||||||||||||||||||||||||||||||
| 275 | if (!object) { | - | ||||||||||||||||||||||||||||||
| 276 | QMessageLogger(__FILE__, 384383, __PRETTY_FUNCTION__).warning("QEventDispatcherUNIX:registeredTimers: invalid argument"); | - | ||||||||||||||||||||||||||||||
| 277 | return QList<TimerInfo>(); | - | ||||||||||||||||||||||||||||||
| 278 | } | - | ||||||||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||||||||
| 280 | const QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 281 | return d->timerList.registeredTimers(object); | - | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| QSockNotType::QSockNotType() | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&select_fds)->fds_bits)[0]) : "memory"); } while (0); | ||||||||||||||||||||||||||||||||
| do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&enabled_fds)->fds_bits)[0]) : "memory"); } while (0); | ||||||||||||||||||||||||||||||||
| do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&pending_fds)->fds_bits)[0]) : "memory"); } while (0); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| QSockNotType::~QSockNotType() | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| for (int i = 0; i < list.size(); ++i) | ||||||||||||||||||||||||||||||||
| delete list[i];} | ||||||||||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||||||||
| 284 | - | |||||||||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||||||||
| 288 | void QEventDispatcherUNIX::registerSocketNotifier(QSocketNotifier *notifier) | - | ||||||||||||||||||||||||||||||
| 289 | { | - | ||||||||||||||||||||||||||||||
| 290 | ((!(notifier)) ? qt_assert("notifier",__FILE__,414397) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 291 | int sockfd = notifier->socket(); | - | ||||||||||||||||||||||||||||||
| 292 | intQSocketNotifier::Type type = notifier->type(); | - | ||||||||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||||||||
| 294 | if (sockfd < 0 | 0 | ||||||||||||||||||||||||||||||
| || unsigned(sockfd) >= 1024) { | ||||||||||||||||||||||||||||||||
| QMessageLogger(__FILE__, 420, __PRETTY_FUNCTION__).warning("QSocketNotifier: Internal error"); | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
} elseif (notifier->thread() != thread()
| ||||||||||||||||||||||||||||||||
| 295 | QMessageLogger(__FILE__, 424402, __PRETTY_FUNCTION__).warning("QSocketNotifier: socket notifiers cannot be enabled from another thread"); | - | ||||||||||||||||||||||||||||||
| 296 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 297 | } | - | ||||||||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||||||||
| 300 | QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 301 | QSockNotType::List &listQSocketNotifierSetUNIX &sn_set = d->sn_vec[type].list; | - | ||||||||||||||||||||||||||||||
| fd_set *fds = &d->sn_vecsocketNotifiers[type].enabled_fds; | ||||||||||||||||||||||||||||||||
| QSockNot *sn; | ||||||||||||||||||||||||||||||||
| sn = new QSockNot; | ||||||||||||||||||||||||||||||||
| sn->obj = notifier; | ||||||||||||||||||||||||||||||||
| sn->fd =sockfd; | ||||||||||||||||||||||||||||||||
| sn->queue = &d->sn_vec]; | ||||||||||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||||||||
| 303 | if (sn_set.notifiers
| 0 | ||||||||||||||||||||||||||||||
int i;
| ||||||||||||||||||||||||||||||||
for (i = 0; i < list
| ||||||||||||||||||||||||||||||||
QSockNot *p = list
| ||||||||||||||||||||||||||||||||
if (p->fd < sockfd)
| ||||||||||||||||||||||||||||||||
break;
| ||||||||||||||||||||||||||||||||
if (p->fd == sockfd
| ||||||||||||||||||||||||||||||||
| 304 | { | 0 | ||||||||||||||||||||||||||||||
| static const char *t[] = { "Read", "Write", "Exception" };QMessageLogger(__FILE__, 446411, __PRETTY_FUNCTION__).warning("QSocketNotifier"%s: Multiple socket notifiers for" never executed: QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type)); | ||||||||||||||||||||||||||||||||
| "same never executed: QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type));never executed: same socket %d and type %s",QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type));never executed: QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type)); | ||||||||||||||||||||||||||||||||
| 305 | __PRETTY_FUNCTION__ never executed: QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type));never executed: , sockfd, t[socketType(type]);QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type));never executed: QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type)); | 0 | ||||||||||||||||||||||||||||||
| } never executed: QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type)); | ||||||||||||||||||||||||||||||||
| } never executed: QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type)); | ||||||||||||||||||||||||||||||||
| list never executed: QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type));never executed: ));QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type));never executed: QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("%s: Multiple socket notifiers for same socket %d and type %s", __PRETTY_FUNCTION__, sockfd, socketType(type)); | ||||||||||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||||||||
| 307 | sn_set.insert(i, sn); | - | ||||||||||||||||||||||||||||||
| ((void) (((fds)->fds_bits)[((sockfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((sockfd) % (8 * (int) sizeof (__fd_mask)))))); | ||||||||||||||||||||||||||||||||
| d->sn_highestnotifiers[type] = qMax(d->sn_highest, sockfd);notifier; | ||||||||||||||||||||||||||||||||
| 308 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||||||||
| 310 | void QEventDispatcherUNIX::unregisterSocketNotifier(QSocketNotifier *notifier) | - | ||||||||||||||||||||||||||||||
| 311 | { | - | ||||||||||||||||||||||||||||||
| 312 | ((!(notifier)) ? qt_assert("notifier",__FILE__,458419) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 313 | int sockfd = notifier->socket(); | - | ||||||||||||||||||||||||||||||
| 314 | intQSocketNotifier::Type type = notifier->type(); | - | ||||||||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||||||||
| 316 | if (sockfd < 0 | 0 | ||||||||||||||||||||||||||||||
| || unsigned(sockfd) >= 1024) { | ||||||||||||||||||||||||||||||||
| QMessageLogger(__FILE__, 464, __PRETTY_FUNCTION__).warning("QSocketNotifier: Internal error"); | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
} elseif (notifier->thread() != thread()
| ||||||||||||||||||||||||||||||||
| 317 | QMessageLogger(__FILE__, 468424, __PRETTY_FUNCTION__).warning("QSocketNotifier: socket notifiersnotifier (fd %d) cannot be disabled from another thread"); | - | ||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| QEventDispatcherUNIXPrivate * const d = d_func(); | ||||||||||||||||||||||||||||||||
| QSockNotType::List &list = d->sn_vec[type].list; | ||||||||||||||||||||||||||||||||
| fd_set *fds = &d->sn_vec[type].enabled_fds; | ||||||||||||||||||||||||||||||||
| QSockNot *sn = 0; | ||||||||||||||||||||||||||||||||
| int i; | ||||||||||||||||||||||||||||||||
| for (i = 0; i < list.size(); ++i) { | ||||||||||||||||||||||||||||||||
| sn = list[i]; | ||||||||||||||||||||||||||||||||
| if(sn->obj == notifier && sn->fd == sockfd) | ||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| if (i == list.size()) | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| ((void) (((fds)->fds_bits)[((sockfd) / (8 * (int) sizeof (__fd_mask)))] &= ~((__fd_mask) 1 << ((sockfd) % (8 * (int) sizeof (__fd_mask)))))); | ||||||||||||||||||||||||||||||||
| ((void) (((sn->queue)->fds_bits)[((sockfd) / (8 * (int) sizeof (__fd_mask)))] &= ~((__fd_mask) 1 << ((sockfd) % (8 * (int) sizeof (__fd_mask)))))); | ||||||||||||||||||||||||||||||||
| d->sn_pending_list.removeAll(sn); | ||||||||||||||||||||||||||||||||
| listthread.removeAt(i); | ||||||||||||||||||||||||||||||||
| delete sn; | ||||||||||||||||||||||||||||||||
| if\n" | ||||||||||||||||||||||||||||||||
| 318 | "(d->sn_highest == sockfd) { | - | ||||||||||||||||||||||||||||||
| d->sn_highest = -1; | ||||||||||||||||||||||||||||||||
| forNotifier's thread is %s(int i=0; i<3; i++) { | ||||||||||||||||||||||||||||||||
| if (!d->sn_vec[i].list.isEmpty()) | ||||||||||||||||||||||||||||||||
| d->sn_highest = qMax%p), event dispatcher's thread is %s(d->sn_highest, | ||||||||||||||||||||||||||||||||
| d->sn_vec[i].list[0]->fd); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| void QEventDispatcherUNIX::setSocketNotifierPending%p), current thread is %s(QSocketNotifier *notifier) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| ((!(notifier%p))? qt_assert("notifier",__FILE__", | ||||||||||||||||||||||||||||||||
| 319 | 504) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| intsockfd=, | ||||||||||||||||||||||||||||||||
| 320 | notifier->socket(); | - | ||||||||||||||||||||||||||||||
| int type =thread() ? notifier->type(); | ||||||||||||||||||||||||||||||||
| if (sockfd < 0 | ||||||||||||||||||||||||||||||||
| || unsigned(sockfd) >= 1024) { | ||||||||||||||||||||||||||||||||
| QMessageLogger(__FILE__, 510, __PRETTY_FUNCTION__).warning("QSocketNotifierthread()->metaObject()->className() : Internal error"); | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| ((!("QThread", notifier->thread() ==thread() &&(), | ||||||||||||||||||||||||||||||||
| 321 | thread() == QThread::currentThread()))? qt_assert("notifier->thread() == thread()->metaObject()->className() &&: "QThread", thread(), | - | ||||||||||||||||||||||||||||||
| 322 | QThread::currentThread() == ? QThread::currentThread()->metaObject()->className() ",__FILE__,513):qt_noop "QThread", QThread::currentThread()); | - | ||||||||||||||||||||||||||||||
| 323 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 324 | } | - | ||||||||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||||||||
| 326 | - | |||||||||||||||||||||||||||||||
| 327 | QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||||||||
| 329 | QSockNotType::List &list =d->sn_vec[type].list; | - | ||||||||||||||||||||||||||||||
| QSockNot *sn = 0; | ||||||||||||||||||||||||||||||||
| int i; | ||||||||||||||||||||||||||||||||
| forpendingNotifiers.removeOne(notifier); | ||||||||||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||||||||
| 331 | auto i = 0; i < listd->socketNotifiers.size(); ++i) { | - | ||||||||||||||||||||||||||||||
| sn = list[i]; | ||||||||||||||||||||||||||||||||
| iffind(sn->obj == notifier && sn->fd ==sockfd) | ||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
| 332 | if (i == list.size())
| 0 | ||||||||||||||||||||||||||||||
return;
| ||||||||||||||||||||||||||||||||
if (! ((((sn->queue)->fds_bits)[((sn->fd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((sn->fd) % (8 * (int) sizeof (__fd_mask))))) != 0)) {
| ||||||||||||||||||||||||||||||||
if (
| ||||||||||||||||||||||||||||||||
| 333 | { | 0 | ||||||||||||||||||||||||||||||
| d->sn_pending_listreturn; never executed: return; | ||||||||||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||||||||
| 335 | QSocketNotifierSetUNIX &sn_set = i.appendvalue(); | - | ||||||||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||||||||
| 337 | if (sn); | 0 | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||
d->sn_pending_listsn_set
| ||||||||||||||||||||||||||||||||
| 338 | %return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||||||||
| 340 | if (d->sn_pending_listsn_set
| 0 | ||||||||||||||||||||||||||||||
}
| ||||||||||||||||||||||||||||||||
((void) (((sn->queue)->fds_bits)[((sn->fd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((sn->fd) % (8 * (int
| ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| int QEventDispatcherUNIX::activateTimers(){ | ||||||||||||||||||||||||||||||||
| 341 | ((!(thread() == QThread::currentThread())) ? qt_assertQMessageLogger("thread()__FILE__, 448, __PRETTY_FUNCTION__).warning("%s: ==Multiple QThread::currentThread()"socket notifiers for same socket %d and type %s", | - | ||||||||||||||||||||||||||||||
| 342 | __FILE____PRETTY_FUNCTION__, 547) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| QEventDispatcherUNIXPrivate * const d = d_func(); | ||||||||||||||||||||||||||||||||
| return d->timerList.activateTimers(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| int QEventDispatcherUNIX::activateSocketNotifiers() | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| QEventDispatcherUNIXPrivate * const d = d_func(); | ||||||||||||||||||||||||||||||||
| ifsockfd, socketType(d->sn_pending_list.isEmpty())type)); | ||||||||||||||||||||||||||||||||
| 343 | return never executed: 0;return;never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 344 | int n_act} | - | ||||||||||||||||||||||||||||||
| 345 | - | |||||||||||||||||||||||||||||||
| 346 | sn_set.notifiers[type] = 0nullptr; | - | ||||||||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||||||||
| 348 | QEvent eventif (QEvent::SockAct); | 0 | ||||||||||||||||||||||||||||||
while (!d->sn_pending_listsn_set
| ||||||||||||||||||||||||||||||||
| 349 | { | 0 | ||||||||||||||||||||||||||||||
| QSockNot *sn =d->sn_pending_listsocketNotifiers.takeFirst(); never executed: d->socketNotifiers.erase(i); | ||||||||||||||||||||||||||||||||
| if (((((sn->queue)->fds_bits)[((sn->fd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((sn->fd) % (8 * (int) sizeof (__fd_mask))))) != 0)) { never executed: d->socketNotifiers.erase(i); | ||||||||||||||||||||||||||||||||
| ((void) (((sn->queue)->fds_bits)[((sn->fd) / (8 * (int) sizeof (__fd_mask)))] &= ~((__fd_mask) 1 << ((sn->fd) % (8 * (int) sizeof (__fd_mask)))))); never executed: d->socketNotifiers.erase(i); | ||||||||||||||||||||||||||||||||
| QCoreApplication::sendEvent never executed: d->socketNotifiers.erase(i);never executed: erase(sn->obj, &eventi);d->socketNotifiers.erase(i);never executed: d->socketNotifiers.erase(i); | ||||||||||||||||||||||||||||||||
| ++n_act; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| return n_act;} never executed: end of block | ||||||||||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||||||||
| 352 | bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags) | - | ||||||||||||||||||||||||||||||
| 353 | { | - | ||||||||||||||||||||||||||||||
| 354 | QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 355 | d->interrupt.store(0); | - | ||||||||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||||||||
| 358 | awake(); | - | ||||||||||||||||||||||||||||||
| 359 | QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); | - | ||||||||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||||||||
| 361 | int neventsconst bool include_timers = (flags & QEventLoop::X11ExcludeTimers) == 0; | - | ||||||||||||||||||||||||||||||
| 362 | const bool include_notifiers = (flags & QEventLoop::ExcludeSocketNotifiers) == 0; | - | ||||||||||||||||||||||||||||||
| 363 | const bool wait_for_events = flags & QEventLoop::WaitForMoreEvents; | - | ||||||||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||||||||
| 365 | const bool canWait = (d->threadData->canWaitLocked()
| 0 | ||||||||||||||||||||||||||||||
| 366 | && !d->interrupt.load()
| 0 | ||||||||||||||||||||||||||||||
| 367 | && (flags & QEventLoop::WaitForMoreEvents));wait_for_events
| 0 | ||||||||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||||||||
| 369 | if (canWait
| 0 | ||||||||||||||||||||||||||||||
| 370 | aboutToBlock(); never executed: aboutToBlock(); | 0 | ||||||||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||||||||
| 372 | if (!(d->interrupt.load()
| 0 | ||||||||||||||||||||||||||||||
| 373 | {return never executed: return false;never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||||||||
| 375 | timespec *tm = 0nullptr; | - | ||||||||||||||||||||||||||||||
| 376 | timespec wait_tm = { 0l0, 0l0 }; | - | ||||||||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||||||||
| 378 | if (!(flags & QEventLoop::X11ExcludeTimers)) {if (!canWait
| 0 | ||||||||||||||||||||||||||||||
| 379 | tm = &wait_tm; never executed: tm = &wait_tm; | 0 | ||||||||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||||||||
| 381 | } | - | ||||||||||||||||||||||||||||||
| if (!canWait) {d->pollfds.clear(); | ||||||||||||||||||||||||||||||||
| 382 | d->pollfds.reserve(1 + (include_notifiers ? d->socketNotifiers.size() : 0)); | - | ||||||||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||||||||
| 384 | if (!tm(include_notifiers
| 0 | ||||||||||||||||||||||||||||||
| 385 | tmfor (auto it = &wait_tm; | 0 | ||||||||||||||||||||||||||||||
tmd->tv_secsocketNotifiers.cbegin(); it != d->socketNotifiers.cend()
| ||||||||||||||||||||||||||||||||
| 386 | d->pollfds.append(qt_make_pollfd(it.key(), it.value().events())); never executed: d->pollfds.append(qt_make_pollfd(it.key(), it.value().events())); | 0 | ||||||||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||||||||
| 389 | d->pollfds.append(d->threadPipe.prepare()); | - | ||||||||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||||||||
| 391 | int nevents = 0l0; | - | ||||||||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||||||||
| 393 | tmswitch (qt_safe_poll(d->tv_nsec = 0lpollfds.data(), d->pollfds.size(), tm)) { | - | ||||||||||||||||||||||||||||||
| 394 | case never executed: -1:case -1:never executed: case -1: | 0 | ||||||||||||||||||||||||||||||
| 395 | perror("qt_safe_poll"); | - | ||||||||||||||||||||||||||||||
| 396 | break never executed: break;never executed: break;never executed: ;break;never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 397 | }case never executed: case 0:never executed: 0:case 0:never executed: case 0: | 0 | ||||||||||||||||||||||||||||||
| 398 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 399 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 400 | nevents =+= d->doSelectthreadPipe.check(flags, tm);d->pollfds.takeLast()); | - | ||||||||||||||||||||||||||||||
| 401 | if (!(flags & QEventLoop::X11ExcludeTimers)) {include_notifiers
| 0 | ||||||||||||||||||||||||||||||
| 402 | nevents += activateTimersd->activateSocketNotifiers(); never executed: nevents += d->activateSocketNotifiers(); | 0 | ||||||||||||||||||||||||||||||
| 403 | }break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 404 | } | - | ||||||||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||||||||
| 406 | if (include_timers
| 0 | ||||||||||||||||||||||||||||||
| 407 | nevents += d->activateTimers(); never executed: nevents += d->activateTimers(); | 0 | ||||||||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||||||||
| 410 | return never executed: (nevents > 0);return (nevents > 0);never executed: return (nevents > 0); | 0 | ||||||||||||||||||||||||||||||
| 411 | } | - | ||||||||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||||||||
| 413 | bool QEventDispatcherUNIX::hasPendingEvents() | - | ||||||||||||||||||||||||||||||
| 414 | { | - | ||||||||||||||||||||||||||||||
| 415 | extern uint qGlobalPostedEventsCount(); | - | ||||||||||||||||||||||||||||||
| 416 | return qGlobalPostedEventsCount(); | - | ||||||||||||||||||||||||||||||
| 417 | } | - | ||||||||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||||||||
| 419 | int QEventDispatcherUNIX::remainingTime(int timerId) | - | ||||||||||||||||||||||||||||||
| 420 | { | - | ||||||||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||||||||
| 422 | if (timerId < 1) { | - | ||||||||||||||||||||||||||||||
| 423 | QMessageLogger(__FILE__, 628530, __PRETTY_FUNCTION__).warning("QEventDispatcherUNIX::remainingTime: invalid argument"); | - | ||||||||||||||||||||||||||||||
| 424 | return -1; | - | ||||||||||||||||||||||||||||||
| 425 | } | - | ||||||||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||||||||
| 428 | QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 429 | return d->timerList.timerRemainingTime(timerId); | - | ||||||||||||||||||||||||||||||
| 430 | } | - | ||||||||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||||||||
| 432 | void QEventDispatcherUNIX::wakeUp() | - | ||||||||||||||||||||||||||||||
| 433 | { | - | ||||||||||||||||||||||||||||||
| 434 | QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 435 | if (d->wakeUpsthreadPipe.testAndSetAcquire(0, 1)) { | - | ||||||||||||||||||||||||||||||
| if (d->thread_pipe[1] == -1) { | ||||||||||||||||||||||||||||||||
| eventfd_t value = 1; | ||||||||||||||||||||||||||||||||
| int ret; | ||||||||||||||||||||||||||||||||
| do { ret = eventfd_write(d->thread_pipe[0], value); } while (ret == -1 && (*__errno_location ()) == 4); | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| char c = 0; | ||||||||||||||||||||||||||||||||
| qt_safe_write( d->thread_pipe[1], &c, 1 ); | ||||||||||||||||||||||||||||||||
| }wakeUp(); | ||||||||||||||||||||||||||||||||
| 436 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 437 | - | |||||||||||||||||||||||||||||||
| 438 | void QEventDispatcherUNIX::interrupt() | - | ||||||||||||||||||||||||||||||
| 439 | { | - | ||||||||||||||||||||||||||||||
| 440 | QEventDispatcherUNIXPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 441 | d->interrupt.store(1); | - | ||||||||||||||||||||||||||||||
| 442 | wakeUp(); | - | ||||||||||||||||||||||||||||||
| 443 | } | - | ||||||||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||||||||
| 445 | void QEventDispatcherUNIX::flush() | - | ||||||||||||||||||||||||||||||
| 446 | { } | - | ||||||||||||||||||||||||||||||
| 447 | - | |||||||||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |