pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Murphy <joe.murphy@aersoft.ie>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Joe Murphy <joe.murphy@aersoft.ie>
Cc: pgsql-interfaces@postgresql.org <pgsql-interfaces@postgresql.org>
Subject: Re: libpq, threads and connection reset
Date: Fri, 06 Sep 2002 11:31:47 +0100
Message-ID: <3D788412.CCFB57E2@aersoft.com> (raw)
References: <20020828025202.C74E81D1943C8@bjapp2.163.net>
	<3D7751B5.CE431206@aersoft.com>
	<3D775423.78A43764@aersoft.com>
	<29109.1031235564@sss.pgh.pa.us>

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
The problem I was having "went away" when I moved to another Solaris 2.6
machine with the latest patch level.
<br>I've also tested it on Solaris 8, HP-UX 11.00 and Linux, so it looks
like there is a connect bug in a release 2.6,
<br>but seems to be fixed with later patches.
<p>Thanks for the help.
<p>Joe
<p>Tom Lane wrote:
<blockquote TYPE=CITE>Joe Murphy &lt;joe.murphy@aersoft.ie> writes:
<br>>> The re-connect underlying call to connect returns -1 and errno =
0, so
<br>>> it thinks the connection is "in progress" and tries
<br>>> to complete the connection - but hangs on the select (poll)
<p>Well, you have a bug in connect() if it's returning the wrong errno
<br>in the multi-thread case.
<p>However, our code in fe-connect.c reads like this:
<p>&nbsp;&nbsp;&nbsp; if (connect(conn->sock, &amp;conn->raddr.sa, conn->raddr_len)
&lt; 0)
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (SOCK_ERRNO == EINTR)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/* Interrupted system call - we'll just try again */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
goto retry1;
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (SOCK_ERRNO == EINPROGRESS
|| SOCK_ERRNO == EWOULDBLOCK || SOCK_ERRNO == 0)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/*
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
* This is fine - we're in non-blocking mode, and the
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
* connection is in progress.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
*/
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
conn->status = CONNECTION_STARTED;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/* Something's gone wrong */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
connectFailureMessage(conn, SOCK_ERRNO);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
goto connect_errReturn;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<p>I wonder whether it's really a good idea to treat errno == 0 as
<br>indicating "connection in progress".&nbsp; Does anyone know of a platform
<br>where zero is actually what is returned in this case?&nbsp; The man
pages
<br>I can find all say that EINPROGRESS is returned.
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
regards, tom lane
<p>---------------------------(end of broadcast)---------------------------
<br>TIP 4: Don't 'kill -9' the postmaster</blockquote>

<pre>--&nbsp;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Joe Murphy - AerSoft Limited
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 Northumberland Avenue, Dun Laoghaire, Co. Dublin.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; phone: +353-1-2301166&nbsp;&nbsp;&nbsp;&nbsp; direct: +353-1-2145953&nbsp;&nbsp;&nbsp;&nbsp; fax: +353-1-2301167&nbsp;&nbsp;
&nbsp; <A HREF="mailto:joe@aersoft.com">mailto:joe@aersoft.com</A>&nbsp;&nbsp; mobile: +353-86-8526181&nbsp; <A HREF="http://www.aersoft.com">http://www.aersoft.com</A>&nbsp;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</pre>
&nbsp;</html>




view thread (5+ messages)

Message-ID: <3D788412.CCFB57E2@aersoft.com>
Permalink:  ../3D788412.CCFB57E2@aersoft.com/
Also on:    postgresql.org/message-id/3D788412.CCFB57E2@aersoft.com

 · 

reply

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: joe.murphy@aersoft.ie, tgl@sss.pgh.pa.us
  Subject: Re: libpq, threads and connection reset
  In-Reply-To: <3D788412.CCFB57E2@aersoft.com>

* 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