Qt patch: Redo select on EINTR "error" (QLocalSocket)

Thiago Macieira thiago at kde.org
Mon Nov 10 06:15:04 GMT 2008


Daniel Winter wrote:
>Can someone please take a look at the patch ( I think it ?is not really
>optimal as it is, but it fixes the issue with Soprano )? ?What needs to
> be done to get it in the qt-copy patch set?

This was already fixed for Qt 4.4.4. See Qt task 226687.

Attaching the official patch instead. Feel free to add it to qt-copy.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 52584c2..c89f189 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -838,10 +838,15 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co
     tv.tv_sec = timeout / 1000;
     tv.tv_usec = (timeout % 1000) * 1000;

-    if (selectForRead)
-        return select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
-    else
-        return select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
+    int retval;
+    do {
+        if (selectForRead)
+            retval = select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
+        else
+            retval = select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
+    } while (retval == -1 && errno == EINTR);
+
+    return retval;
 }

 int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool checkWrite,
@@ -861,7 +866,10 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c
     tv.tv_sec = timeout / 1000;
     tv.tv_usec = (timeout % 1000) * 1000;

-    int ret = select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv);
+    int ret;
+    do {
+        ret = select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv);
+    } while (ret == -1 && errno == EINTR);
     if (ret <= 0)
         return ret;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20081110/61e07e7f/attachment.sig>


More information about the kde-core-devel mailing list