summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2010-04-12 15:19:59 (GMT)
committerJanne Anttila <janne.anttila@digia.com>2010-04-12 15:29:01 (GMT)
commit4049dc98f1437cbbfdde5bd1ac16a7e69d65d254 (patch)
tree23b69411fc747a477bd99e4a4f1fe1073dbb5b67 /src/network
parent07c347f5401754ebcf15ac2b6aae2cfbdf7b8654 (diff)
downloadQt-4049dc98f1437cbbfdde5bd1ac16a7e69d65d254.zip
Qt-4049dc98f1437cbbfdde5bd1ac16a7e69d65d254.tar.gz
Qt-4049dc98f1437cbbfdde5bd1ac16a7e69d65d254.tar.bz2
Fixed app freeze if switching to offline in middle of HTTP transaction.
When active socket is disconnected by swithcing to offline mode, native RSocket completes the active socket operations with KErrCancel (-3). Open C maps this error code to POSIX errno EINTR (4). Normally in Posix EINTR is only used to indicate that some operation was interrupted by POSIX signal. Qt has a while loops in network operations to handle operations interrupterd by signals. These while loops will be effectively forever loops in Symbian due to Open C error code mapping. Because Symbian does not have native support for signals, i.e. the network operations can never be really interrupted by POSIX signal, it is ok to remove these while loops completely on Symbian platform. This fix is a workaround to Open C incorrect error mapping, and should be removed once Open C has fixed their error mapping. Task-number: QT-3274 Reviewed-by: Aleksandar Sasha Babic
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 9a2c349..354c944 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -601,10 +601,15 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
// Peek 0 bytes into the next message. The size of the message may
// well be 0, so we can't check recvfrom's return value.
ssize_t readBytes;
+#ifdef Q_OS_SYMBIAN
+ char c;
+ readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
+#else
do {
char c;
readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
} while (readBytes == -1 && errno == EINTR);
+#endif
// If there's no error, or if our buffer was too small, there must be a
// pending datagram.
@@ -661,11 +666,17 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
sz = sizeof(aa);
ssize_t recvFromResult = 0;
+#ifdef Q_OS_SYMBIAN
+ char c;
+ recvFromResult = ::recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
+ 0, &aa.a, &sz);
+#else
do {
char c;
recvFromResult = ::recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
0, &aa.a, &sz);
} while (recvFromResult == -1 && errno == EINTR);
+#endif
if (recvFromResult == -1) {
setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString);
@@ -832,17 +843,17 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
// ignore the SIGPIPE signal
qt_ignore_sigpipe();
- // loop while ::write() returns -1 and errno == EINTR, in case
- // of an interrupting signal.
ssize_t writtenBytes;
- do {
#ifdef Q_OS_SYMBIAN
- writtenBytes = ::write(socketDescriptor, data, len);
+ // Symbian does not support signals natively and Open C returns EINTR when moving to offline
+ writtenBytes = ::write(socketDescriptor, data, len);
#else
+ // loop while ::write() returns -1 and errno == EINTR, in case
+ // of an interrupting signal.
+ do {
writtenBytes = qt_safe_write(socketDescriptor, data, len);
-#endif
- // writtenBytes = QT_WRITE(socketDescriptor, data, len); ### TODO S60: Should this line be removed or the one above it?
} while (writtenBytes < 0 && errno == EINTR);
+#endif
if (writtenBytes < 0) {
switch (errno) {
@@ -882,13 +893,13 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize)
}
ssize_t r = 0;
- do {
#ifdef Q_OS_SYMBIAN
- r = ::read(socketDescriptor, data, maxSize);
+ r = ::read(socketDescriptor, data, maxSize);
#else
+ do {
r = qt_safe_read(socketDescriptor, data, maxSize);
-#endif
} while (r == -1 && errno == EINTR);
+#endif
if (r < 0) {
r = -1;