Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A9E2D14E23D3 for ; Wed, 21 Dec 2011 12:00:55 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RdOb6-00053x-Le for pgsql-bugs@postgresql.org; Wed, 21 Dec 2011 16:00:55 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pBLG0Yje005745; Wed, 21 Dec 2011 11:00:34 -0500 (EST) To: "Andrea Grassi" cc: "'Craig Ringer'" , harrywr2@comcast.net, "'Pg Bugs'" , "'Alvaro Herrera'" Subject: Re: R: R: R: R: R: BUG #6342: libpq blocks forever in "poll" function In-reply-to: <000c01ccbfd6$1d5a5e70$580f1b50$@com> References: <4EEB0006.7080205@ringerc.id.au> <001201ccbbfc$82c987a0$885c96e0$@com> <4EEC3462.80702@ringerc.id.au> <000601ccbef6$060820d0$12186270$@com> <1324395708-sup-4443@alvh.no-ip.org> <001701ccbf34$72480970$56d81c50$@com> <20092.1324399103@sss.pgh.pa.us> <002301ccbf3c$cc34b110$649e1330$@com> <6410.1324402946@sss.pgh.pa.us> <4EF12097.5060907@ringerc.id.au> <000c01ccbfd6$1d5a5e70$580f1b50$@com> Comments: In-reply-to "Andrea Grassi" message dated "Wed, 21 Dec 2011 12:46:01 +0100" Date: Wed, 21 Dec 2011 11:00:34 -0500 Message-ID: <5744.1324483234@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -4.5 (----) X-Archive-Number: 201112/189 X-Sequence-Number: 32000 "Andrea Grassi" writes: > In internet I searched for detailed specifications of poll/select system > functions but I didn't understand one thing, that is which one of the 2 > statement is true: > 1) poll/select wait only for FUTURE modifications of ready-read state of > sockets > 2) poll/select check if there is something to read at the moment of the call > and otherwise wait for FUTURE modifications of ready-read state #1 is nonsense. If poll worked like that, it would be impossible for anyone to use it without suffering from race conditions. But if you don't see where exactly the poll() specification says so, I observe that it says first that poll sets the bit(s) if the requested condition is true, and second that *if* none of the events have occurred yet, poll should wait. See for instance http://pubs.opengroup.org/onlinepubs/007908799/xsh/poll.html regards, tom lane