On Mon, 2003-02-10 at 19:55, Mihai RUSU wrote: 
> >     /* blocking cel mult tout_sec */
> >     if((res = select(fd + 1, &rd_set, NULL, NULL, &tv)) <= 0){
> >             /* error or timeout */
> >             return res;
> >     }
> >
> 
> Dar nu avem aici a race condition ?
> Teoretic intre select si read se poate intampla ceva ca read-ul sa se
> blocheze. So O_NONBLOCK ramane de baza (chiar daca faci select() inainte)

Nu prea are ce sa se intample... Aici nu e vorba de acces concurent la
socket (asa ceva oricum nu are sens), un singur thread lucreaza cu el -
no race. Daca select zice ca e readable, inseamna ca exista ceva in
buffer (sau a pleznit conexiunea) iar chestia aia nu dispare din senin. 

man select:

Three independent sets of descriptors are  watched. Those listed in
readfds will be watched to see if characters become available for read‐
ing (more precisely, to see if a read will not block ‐ in particular, a
file  descriptor  is also ready on end‐of‐file), those in writefds will
be watched to see if a write will not block,  and  those  in  exceptfds
will  be  watched  for  exceptions.

Cu alte cuvinte se _garanteaza_ ca urmatorul read va fi non-blocking.

Codul este as safe as it gets ;)

-- 
Florin Malita      web:        http://www.malinux.net
                   public key: http://www.malinux.net/data/fmalita.gpg

-- Attached file included as plaintext by Listar --
-- File: signature.asc
-- Desc: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQA+SAD69npXhj/Ohf8RAlUUAJ0UeAWDZViVz9QggtHSWW3FPvB1NQCdGhLM
QatbC3K16GRvd1/mzepraXY=
=RcwO
-----END PGP SIGNATURE-----


--
Pentru dezabonare, trimiteti mail la 
[EMAIL PROTECTED] cu subiectul 'unsubscribe rlug'.
REGULI, arhive si alte informatii: http://www.lug.ro/mlist/


Raspunde prin e-mail lui