summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qsymbiansocketengine.cpp
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-01-31 18:35:01 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-02-03 14:37:18 (GMT)
commitc466df7e67b1af663be73fca94bb1f2951ba7371 (patch)
tree83894a33db54b0159513189f56de6c6cbde6d67f /src/network/socket/qsymbiansocketengine.cpp
parentc8a1b65ab2491886ac37a1726b3728e549d505a7 (diff)
downloadQt-c466df7e67b1af663be73fca94bb1f2951ba7371.zip
Qt-c466df7e67b1af663be73fca94bb1f2951ba7371.tar.gz
Qt-c466df7e67b1af663be73fca94bb1f2951ba7371.tar.bz2
Fix for pendingDatagramSize() in symbian socket engine
The low level socket option returns the size including IP headers, as there is an option in receive to include headers in the datagram. This is OK for a "size will not exceed" metric for buffer allocation, but Qt relies on it being an accurate size. Open C did this by subtracting 28, but that isn't valid for IPv6 which has a 40 byte header. (we can't tell whether the buffered datagram was received over IPv4 or IPv6) To fix this, do a read with the peek option set, and only care about the size. In future it would be good to not peek, but rather return this buffer to a following call to readDatagram. Reviewed-by: Aaron Tunney
Diffstat (limited to 'src/network/socket/qsymbiansocketengine.cpp')
-rw-r--r--src/network/socket/qsymbiansocketengine.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/network/socket/qsymbiansocketengine.cpp b/src/network/socket/qsymbiansocketengine.cpp
index 6825374..f2c7b20 100644
--- a/src/network/socket/qsymbiansocketengine.cpp
+++ b/src/network/socket/qsymbiansocketengine.cpp
@@ -788,6 +788,20 @@ qint64 QSymbianSocketEngine::pendingDatagramSize() const
Q_D(const QSymbianSocketEngine);
int nbytes;
TInt err = d->nativeSocket.GetOpt(KSOReadBytesPending,KSOLSocket, nbytes);
+ if (nbytes > 0) {
+ //nbytes includes IP header, which is of variable length (IPv4 with or without options, IPv6...)
+ QByteArray next(nbytes,0);
+ TPtr8 buffer((TUint8*)next.data(), next.size());
+ TInetAddr addr;
+ TRequestStatus status;
+ //TODO: rather than peek, should we save this for next call to readDatagram?
+ //what if calls don't match though?
+ d->nativeSocket.RecvFrom(buffer, addr, KSockReadPeek, status);
+ User::WaitForRequest(status);
+ if (status.Int())
+ return 0;
+ return buffer.Length();
+ }
return qint64(nbytes);
}