tst_QUdpSocket: send two bytes in a datagram

I'm getting an error with WSARecvFrom in nativeBytesAvailable() and I
don't know why. The number of bytes obtained is correct and the test
works for 2 bytes, so let's use that.

The Windows nativeBytesAvailable() function has a comment saying that
WSAIoctl sometimes indicates 1 byte available when there's a pending
error notification, so that function proceeds to do a WSARecvFrom to
peek the number of bytes. Somehow that function in this test is getting
a SOCKET_ERROR I can't explain.

Change-Id: Ic5b19e556e572a72a9df9a405b1fee3b7efb8b24
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Thiago Macieira 2015-03-11 19:53:18 -07:00
parent 954f0d9397
commit 58e4bbc83f

View File

@ -1574,7 +1574,7 @@ void tst_QUdpSocket::readyRead()
QSignalSpy spy(&receiver, SIGNAL(readyRead()));
// send a datagram to that port
sender.writeDatagram("a", makeNonAny(receiver.localAddress()), port);
sender.writeDatagram("aa", makeNonAny(receiver.localAddress()), port);
// wait a little
// if QTBUG-43857 is still going, we'll live-lock on socket notifications from receiver's socket
@ -1583,8 +1583,8 @@ void tst_QUdpSocket::readyRead()
// make sure only one signal was emitted
QCOMPARE(spy.count(), 1);
QVERIFY(receiver.hasPendingDatagrams());
QCOMPARE(receiver.bytesAvailable(), qint64(1));
QCOMPARE(receiver.pendingDatagramSize(), qint64(1));
QCOMPARE(receiver.bytesAvailable(), qint64(2));
QCOMPARE(receiver.pendingDatagramSize(), qint64(2));
// write another datagram
sender.writeDatagram("ab", makeNonAny(receiver.localAddress()), port);
@ -1594,7 +1594,7 @@ void tst_QUdpSocket::readyRead()
QCOMPARE(spy.count(), 1);
QVERIFY(receiver.hasPendingDatagrams());
QVERIFY(receiver.bytesAvailable() >= 1); // most likely is 1, but it could be 1 + 2 in the future
QCOMPARE(receiver.pendingDatagramSize(), qint64(1));
QCOMPARE(receiver.pendingDatagramSize(), qint64(2));
// read all the datagrams (we could read one only, but we can't be sure the OS is queueing)
while (receiver.hasPendingDatagrams())