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

Thiago Macieira thiago at kde.org
Mon Nov 10 10:29:43 GMT 2008

Johannes Sixt wrote:
>Thiago Macieira schrieb:
>> 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.
>+    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);
>This seems to rely on that select() updates tv. Isn't this
> Linux-specific? Shouldn't this (at least on other platforms) calculate
> the new tv value from the elapsed time, like in Daniel's patch?

You're right. Thanks for pointing this out.

This is what the man page says:
       On Linux, select() modifies timeout to reflect the amount of time 
not slept; most  other
       implementations  do  not  do this.  (POSIX.1-2001 permits either 
behavior.)  This causes
       problems both when Linux code which reads timeout is ported to 
other operating  systems,
       and  when code is ported to Linux that reuses a struct timeval for 
multiple select()s in
       a loop without reinitializing it.  Consider  timeout  to  be  
undefined  after  select()

I'll have to update the patch in Qt then.
  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 --------------
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/0c41d798/attachment.sig>

More information about the kde-core-devel mailing list