Re: libpq, threads and connection reset

From: Joe Murphy <joe(dot)murphy(at)aersoft(dot)ie>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Joe Murphy <joe(dot)murphy(at)aersoft(dot)ie>, "pgsql-interfaces(at)postgresql(dot)org" <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: libpq, threads and connection reset
Date: 2002-09-06 10:31:47
Message-ID: 3D788412.CCFB57E2@aersoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

<!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(dot)murphy(at)aersoft(dot)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(at)aersoft(dot)com">mailto:joe(at)aersoft(dot)com</A>&nbsp;&nbsp; mobile: +353-86-8526181&nbsp; <A HREF="http://www.aersoft.com">http://www.aersoft.com</A>&nbsp;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</pre>
&nbsp;</html>

Attachment Content-Type Size
unknown_filename text/html 3.7 KB

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Gerhard Häring 2002-09-08 17:35:49 [ANN] pyPgSQL 2.2 is released
Previous Message Rene Kiessig 2002-09-06 10:08:10 Views in pgaccess