From b0b8d8f7a65e31c0edabe7fbe6ee91bb62a67d7c Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Fri, 2 Oct 2009 12:00:11 +0200 Subject: Dealing with socket that was signalized on exception fds set It turns out that if socket was signalized via exception fds set, we should signalize only write notifier in the case where both read and write notifiers exist. If in this case we send signal to read notification socket will prematurely be closed. x#Reviewed-by: Janne Antilla --- src/network/socket/qnativesocketengine_unix.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 2bf9858..f890d12 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -1018,10 +1018,12 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c if(selectForExec) { qWarning("nativeSelect (checkRead %d, checkWrite %d, ret %d, errno %d): Unexpected expectfds ready in fd %d", checkRead, checkWrite, ret, errno, socketDescriptor); - if (checkRead) - FD_SET(socketDescriptor, &fdread); - if (checkWrite) + if (checkWrite){ + FD_CLR(socketDescriptor, &fdread); FD_SET(socketDescriptor, &fdwrite); + } else if (checkRead) + FD_SET(socketDescriptor, &fdread); + if ((ret == -1) && ( errno == ECONNREFUSED || errno == EPIPE )) ret = 1; -- cgit v0.12