Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E391E476C83 for ; Fri, 6 Sep 2002 06:31:46 -0400 (EDT) Received: from nereid.aersoft.ie (nereid.aersoft.ie [194.125.107.131]) by postgresql.org (Postfix) with ESMTP id D74B2476264 for ; Fri, 6 Sep 2002 06:31:45 -0400 (EDT) Received: from aersoft.com (saturn [192.168.0.7]) by nereid.aersoft.ie (Sun Internet Mail Server sims.4.0.2000.10.12.16.25.p8) with ESMTP id <0H200026TIKZH3@nereid.aersoft.ie> for pgsql-interfaces@postgresql.org; Fri, 6 Sep 2002 11:31:47 +0100 (BST) Date: Fri, 06 Sep 2002 11:31:47 +0100 From: Joe Murphy Subject: Re: libpq, threads and connection reset To: Tom Lane Cc: Joe Murphy , "pgsql-interfaces@postgresql.org" Message-id: <3D788412.CCFB57E2@aersoft.com> MIME-version: 1.0 X-Mailer: Mozilla 4.79 [en] (X11; U; SunOS 5.6 sun4u) Content-type: text/html; charset=us-ascii Content-transfer-encoding: 7BIT X-Accept-Language: en References: <20020828025202.C74E81D1943C8@bjapp2.163.net> <3D7751B5.CE431206@aersoft.com> <3D775423.78A43764@aersoft.com> <29109.1031235564@sss.pgh.pa.us> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/47 X-Sequence-Number: 3108 The problem I was having "went away" when I moved to another Solaris 2.6 machine with the latest patch level.
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,
but seems to be fixed with later patches.

Thanks for the help.

Joe

Tom Lane wrote:

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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        Joe Murphy - AerSoft Limited
             2 Northumberland Avenue, Dun Laoghaire, Co. Dublin.            
  phone: +353-1-2301166     direct: +353-1-2145953     fax: +353-1-2301167  
  mailto:joe@aersoft.com   mobile: +353-86-8526181  http://www.aersoft.com 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~