Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 66D074762D7 for ; Thu, 5 Sep 2002 10:19:28 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B677E475F84 for ; Thu, 5 Sep 2002 10:19:27 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g85EJOZM029110; Thu, 5 Sep 2002 10:19:24 -0400 (EDT) To: Joe Murphy Cc: "pgsql-interfaces@postgresql.org" Subject: Re: libpq, threads and connection reset In-reply-to: <3D775423.78A43764@aersoft.com> References: <20020828025202.C74E81D1943C8@bjapp2.163.net> <3D7751B5.CE431206@aersoft.com> <3D775423.78A43764@aersoft.com> Comments: In-reply-to Joe Murphy message dated "Thu, 05 Sep 2002 13:54:59 +0100" Date: Thu, 05 Sep 2002 10:19:24 -0400 Message-ID: <29109.1031235564@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/43 X-Sequence-Number: 3104 Joe Murphy writes: >> The re-connect underlying call to connect returns -1 and errno = 0, so >> it thinks the connection is "in progress" and tries >> to complete the connection - but hangs on the select (poll) Well, you have a bug in connect() if it's returning the wrong errno in the multi-thread case. However, our code in fe-connect.c reads like this: if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) < 0) { if (SOCK_ERRNO == EINTR) /* Interrupted system call - we'll just try again */ goto retry1; if (SOCK_ERRNO == EINPROGRESS || SOCK_ERRNO == EWOULDBLOCK || SOCK_ERRNO == 0) { /* * This is fine - we're in non-blocking mode, and the * connection is in progress. */ conn->status = CONNECTION_STARTED; } else { /* Something's gone wrong */ connectFailureMessage(conn, SOCK_ERRNO); goto connect_errReturn; } I wonder whether it's really a good idea to treat errno == 0 as indicating "connection in progress". Does anyone know of a platform where zero is actually what is returned in this case? The man pages I can find all say that EINPROGRESS is returned. regards, tom lane