[Qt-interest] Major bug in QAbstractSocket's method waitForReadyRead()
Patric
userqt at gmail.com
Wed Jun 24 01:11:34 CEST 2009
Hello, please take a look at this.
I have a class here. It's called SNMP session and it sends some simple get and set requests. It uses QUdpSocket and have few other fields :
QUdpSocket udpSocket;
QHostAddress *agentAddress;
qint16 agentPort;
qint16 socketPort;
Here is the constructor :
SNMPSession::SNMPSession(const QString &agentAddress, qint16 agentPort, qint16 socketPort)
: QObject()
{
this->agentAddress = new QHostAddress(agentAddress);
this->agentPort = agentPort;
this->socketPort = socketPort;
udpSocket.bind(socketPort);
}
Nothing sophisticated. Here I have some test code which shows the bug I'm talking about :
SNMPSession session("192.168.0.100", 161, 162);
int error;
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
error = session.sendSetRequest("private", "1.3.6.1.4.1.32324.1.4.4.1.0", "test");
In my methods (sendSetRequest and sendGetRequest) I have the following line :
if(udpSocket.waitForReadyRead(5000))
{
receivedDatagram.resize(udpSocket.pendingDatagramSize());
udpSocket.readDatagram(receivedDatagram.data(), receivedDatagram.size());
return receivedDatagram.at(errorIndex);
}
I have a sniffer program, more specifically Wireshark. There I can see my requests and my responses. The problem is, that according to that code up there it should wait 5 seconds for the new package. But there are situations when it don't wait, it just returns false. I'm talking for the waitForReadyRead method. So here are the situations :
1. My network cable is plugged in. The first setRequest is successful, so it returns true. After that I'm removing the cable. The second request is unsuccessful, so it waits 5 seconds. And all other requests wait for five seconds. And this is the correct behaviour.
2. My cable IS NOT plugged. The first setRequest is unsuccessful, so it waits 5 seconds and continues with the second. But here ! it don't wait 5 seconds, it immediately returns FALSE. Which I think is not correct.
Please, correct me if I'm wrong. I also have some deadline here and this was very very bad surprise...
Best regards,
Patric
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4098 (20090522) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090624/766decec/attachment.html
More information about the Qt-interest-old
mailing list