diff options
author | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-05-18 07:52:22 (GMT) |
---|---|---|
committer | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-05-18 07:52:22 (GMT) |
commit | e0269d21b32e0b2bc3aec55ab3c66e275a0f7301 (patch) | |
tree | e6367fd0f413bdfe11e6cf7cacc5e7bb914617c6 /src/network | |
parent | ccab28c0a778d5e951ff9d6c9bb5f74fc1a2d97c (diff) | |
download | Qt-e0269d21b32e0b2bc3aec55ab3c66e275a0f7301.zip Qt-e0269d21b32e0b2bc3aec55ab3c66e275a0f7301.tar.gz Qt-e0269d21b32e0b2bc3aec55ab3c66e275a0f7301.tar.bz2 |
Adding to check return value from select() before checking any fd_set status.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/socket/qnativesocketengine_unix.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 21059b1..a3f62db 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -895,7 +895,7 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co fd_set fdexec; FD_ZERO(&fdexec); FD_SET(socketDescriptor, &fdexec); -#endif +#endif QTime timer; timer.start(); @@ -917,7 +917,13 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co #ifdef Q_OS_SYMBIAN - bool selectForExec = FD_ISSET(socketDescriptor, &fdexec); + bool selectForExec = false; + if(retval != 0) { + if(retval < 0) { + qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor); + } + selectForExec = FD_ISSET(socketDescriptor, &fdexec); + } if(selectForExec) { qWarning("nativeSelect (selectForRead %d, retVal %d, errno %d) Unexpected expectfds ready in fd %d", selectForRead, retval, errno, socketDescriptor); @@ -977,7 +983,13 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c ret = qt_socket_select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv); #else ret = qt_socket_select(socketDescriptor + 1, &fdread, &fdwrite, &fdexec, timeout < 0 ? 0 : &tv); - bool selectForExec = FD_ISSET(socketDescriptor, &fdexec); + bool selectForExec = false; + if(ret != 0) { + if(ret < 0) { + qWarning("nativeSelect(....) returned < 0 for socket %d", socketDescriptor); + } + selectForExec = FD_ISSET(socketDescriptor, &fdexec); + } if(selectForExec) { qWarning("nativeSelect (checkRead %d, checkWrite %d, ret %d, errno %d): Unexpected expectfds ready in fd %d", checkRead, checkWrite, ret, errno, socketDescriptor); |