Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.2.0
-
None
-
MacOS 10.9, Qt 5.2.0 commercial
Description
I have an encrypted SSL communication, that reads data from the socket, but strange behavior of received data duplication is observed. I think the readyRead slot is invoked multiple times recursively when we are already in it and process the event (in contrast to the documentation of QIODevice::readyRead)
int counter = 0;
void NetworkManager::onSslData()
{
printf("enter onTcpData %d\n", ++counter); fflush(stdout);
while (mSslSocket.bytesAvailable())
printf("leave onTcpData %d\n", --counter);fflush(stdout);
}
I can see multiple "enter" messages with increasing counter. Then multiple leave messages with decreasing counter. \
If I implement the slot with disconnect from the readyRead while it is being processed, there is no duplication of data in my program and everything seems to work:
void NetworkManager::onSslData()
{
disconnect(&mSslSocket, &QSslSocket::readyRead, this, &NetworkManager::onSslData);
.... process ..
connect(&mSslSocket, &QSslSocket::readyRead, this, &NetworkManager::onSslData);
}