From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joe Murphy <joe.murphy@aersoft.ie>
Cc: pgsql-interfaces@postgresql.org <pgsql-interfaces@postgresql.org>
Subject: Re: libpq, threads and connection reset
Date: Thu, 05 Sep 2002 10:19:24 -0400
Message-ID: <29109.1031235564@sss.pgh.pa.us> (raw)
In-Reply-To: <3D775423.78A43764@aersoft.com>
References: <20020828025202.C74E81D1943C8@bjapp2.163.net>
<3D7751B5.CE431206@aersoft.com>
<3D775423.78A43764@aersoft.com>
Joe Murphy <joe.murphy@aersoft.ie> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, joe.murphy@aersoft.ie
Subject: Re: libpq, threads and connection reset
In-Reply-To: <29109.1031235564@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox