diff options
author | Sami Merilä <sami.merila@nokia.com> | 2009-05-18 09:34:14 (GMT) |
---|---|---|
committer | Sami Merilä <sami.merila@nokia.com> | 2009-05-18 09:34:14 (GMT) |
commit | 7b935a83b0253cdeccad0bd2e53c7a35bec49f36 (patch) | |
tree | 9befbf49b2daad3942eecc22c447fe11050fafa0 /src | |
parent | 53cb9a12aa0de950931f7e0a65cb2ca3fdafeb4b (diff) | |
parent | ff7e53bb99611f8a1a06319d0c17969fda2b9a10 (diff) | |
download | Qt-7b935a83b0253cdeccad0bd2e53c7a35bec49f36.zip Qt-7b935a83b0253cdeccad0bd2e53c7a35bec49f36.tar.gz Qt-7b935a83b0253cdeccad0bd2e53c7a35bec49f36.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_symbian.cpp | 33 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_unix.cpp | 28 |
2 files changed, 54 insertions, 7 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 6c47c7b..3282b7c 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -393,11 +393,29 @@ void QSelectThread::restart() int QSelectThread::updateSocketSet(QSocketNotifier::Type type, fd_set *fds) { int maxfd = 0; - for (QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin(); + if(m_AOStatuses.isEmpty()) { + /* + * Wonder if should return -1 + * to signal that no descriptors + * added to fds + */ + return maxfd; + } + for ( QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin(); i != m_AOStatuses.end(); ++i) { if (i.key()->type() == type) { FD_SET(i.key()->socket(), fds); maxfd = qMax(maxfd, i.key()->socket()); + } else if(type == QSocketNotifier::Exception) { + /* + * We are registering existing sockets + * always to exception set + * + * Doing double FD_SET shouldn't + * matter + */ + FD_SET(i.key()->socket(), fds); + maxfd = qMax(maxfd, i.key()->socket()); } } @@ -407,7 +425,9 @@ int QSelectThread::updateSocketSet(QSocketNotifier::Type type, fd_set *fds) void QSelectThread::updateActivatedNotifiers(QSocketNotifier::Type type, fd_set *fds) { Q_D(QThread); - + if(m_AOStatuses.isEmpty()) { + return; + } QList<QSocketNotifier *> toRemove; for (QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin(); i != m_AOStatuses.end(); ++i) { @@ -416,6 +436,15 @@ void QSelectThread::updateActivatedNotifiers(QSocketNotifier::Type type, fd_set TRequestStatus *status = i.value(); // Thread data is still owned by the main thread. QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); + } else if(type == QSocketNotifier::Exception && FD_ISSET(i.key()->socket(), fds)) { + /* + * check if socket is in exception set + * then signal RequestComplete for it + */ + qWarning("exception on %d", i.key()->socket()); + toRemove.append(i.key()); + TRequestStatus *status = i.value(); + QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone); } } diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index e000e11..a3f62db 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -518,8 +518,14 @@ int QNativeSocketEnginePrivate::nativeAccept() #if defined (QNATIVESOCKETENGINE_DEBUG) qDebug("QNativeSocketEnginePrivate::nativeAccept() == %i", acceptedDescriptor); #endif - // Ensure that the socket is closed on exec*() - qt_socket_fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC); + + //check if we have vaild descriptor at all + if(acceptedDescriptor > 0) { + // Ensure that the socket is closed on exec*() + qt_socket_fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC); + } else { + qWarning("QNativeSocketEnginePrivate::nativeAccept() - acceptedDescriptor <= 0"); + } return acceptedDescriptor; } @@ -889,7 +895,7 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co fd_set fdexec; FD_ZERO(&fdexec); FD_SET(socketDescriptor, &fdexec); -#endif +#endif QTime timer; timer.start(); @@ -911,7 +917,13 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co #ifdef Q_OS_SYMBIAN - bool selectForExec = FD_ISSET(socketDescriptor, &fdexec); + bool selectForExec = false; + if(retval != 0) { + if(retval < 0) { + qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor); + } + selectForExec = FD_ISSET(socketDescriptor, &fdexec); + } if(selectForExec) { qWarning("nativeSelect (selectForRead %d, retVal %d, errno %d) Unexpected expectfds ready in fd %d", selectForRead, retval, errno, socketDescriptor); @@ -971,7 +983,13 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c ret = qt_socket_select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv); #else ret = qt_socket_select(socketDescriptor + 1, &fdread, &fdwrite, &fdexec, timeout < 0 ? 0 : &tv); - bool selectForExec = FD_ISSET(socketDescriptor, &fdexec); + bool selectForExec = false; + if(ret != 0) { + if(ret < 0) { + qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor); + } + selectForExec = FD_ISSET(socketDescriptor, &fdexec); + } if(selectForExec) { qWarning("nativeSelect (checkRead %d, checkWrite %d, ret %d, errno %d): Unexpected expectfds ready in fd %d", checkRead, checkWrite, ret, errno, socketDescriptor); |