diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2010-12-09 10:05:03 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2010-12-09 10:07:19 (GMT) |
commit | b9080b96b05988776daec35f7e2af9ad346abb0a (patch) | |
tree | 63410cfeb10d51d83a4189739c35d1b10d0d3d01 | |
parent | 92f11bd666e8a63d9fc8c5588d843721c5bf68b5 (diff) | |
download | Qt-b9080b96b05988776daec35f7e2af9ad346abb0a.zip Qt-b9080b96b05988776daec35f7e2af9ad346abb0a.tar.gz Qt-b9080b96b05988776daec35f7e2af9ad346abb0a.tar.bz2 |
Fix bug in select
When waitForRead was called, it was selecting for read and write,
because we were checking the pointers instead of the bools.
Reviewed-by: Markus Goetz
-rw-r--r-- | src/network/socket/qsymbiansocketengine.cpp | 10 | ||||
-rw-r--r-- | tests/manual/socketengine/main.cpp | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/network/socket/qsymbiansocketengine.cpp b/src/network/socket/qsymbiansocketengine.cpp index 5cee340..1490bdd 100644 --- a/src/network/socket/qsymbiansocketengine.cpp +++ b/src/network/socket/qsymbiansocketengine.cpp @@ -148,7 +148,11 @@ bool QSymbianSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType so TUint family = (socketProtocol == QAbstractSocket::IPv6Protocol) ? KAfInet6 : KAfInet; TUint type = (socketType == QAbstractSocket::UdpSocket) ? KSockDatagram : KSockStream; TUint protocol = (socketType == QAbstractSocket::UdpSocket) ? KProtocolInetUdp : KProtocolInetTcp; - TInt err = nativeSocket.Open(socketServer, family, type, protocol, *connection); + TInt err; + if (connection) + err = nativeSocket.Open(socketServer, family, type, protocol, *connection); + else + err = nativeSocket.Open(socketServer, family, type, protocol); //TODO: FIXME - deprecated API, make sure we always have a connection instead if (err != KErrNone) { switch (err) { @@ -946,9 +950,9 @@ int QSymbianSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool TPckgBuf<TUint> selectFlags; selectFlags() = KSockSelectExcept; - if (selectForRead) + if (checkRead) selectFlags() |= KSockSelectRead; - if (selectForWrite) + if (checkWrite) selectFlags() |= KSockSelectWrite; TRequestStatus selectStat; nativeSocket.Ioctl(KIOctlSelect, selectStat, &selectFlags, KSOLSocket); diff --git a/tests/manual/socketengine/main.cpp b/tests/manual/socketengine/main.cpp index e475942..2f017a0 100644 --- a/tests/manual/socketengine/main.cpp +++ b/tests/manual/socketengine/main.cpp @@ -109,10 +109,12 @@ int main(int argc, char**argv) } // wait for connected - socketEngine->connectToHost(QHostAddress("74.125.77.99"), 80); // google + int r = socketEngine->connectToHost(QHostAddress("74.125.77.99"), 80); // google bool readyToRead = false; bool readyToWrite = false; socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, true, 10*1000); + if (r <= 0) //timeout or error + exit(1); if (readyToWrite) { // write the request QByteArray request("GET /robots.txt HTTP/1.0\r\n\r\n"); @@ -129,7 +131,11 @@ int main(int argc, char**argv) bzero(buf, bufsize); ret = socketEngine->read(buf, available); if (ret > 0) { +#ifdef Q_OS_SYMBIAN + qDebug() << buf; //printf goes only to screen, this goes to remote debug channel +#else printf("%s", buf); +#endif } else { // some failure when reading exit(1); |