Re: libpq, threads and connection reset - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: libpq, threads and connection reset
Date
Msg-id 29109.1031235564@sss.pgh.pa.us
Whole thread Raw
In response to Re: libpq, threads and connection reset  (Joe Murphy <joe.murphy@aersoft.ie>)
List pgsql-interfaces
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)           /*
Interruptedsystem call - we'll just try again */           goto retry1;
 
       if (SOCK_ERRNO == EINPROGRESS || SOCK_ERRNO == EWOULDBLOCK || SOCK_ERRNO == 0)       {           /*            *
Thisis 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


pgsql-interfaces by date:

Previous
From: Joe Murphy
Date:
Subject: Re: libpq, threads and connection reset
Next
From: Joe Murphy
Date:
Subject: libpq, threads and connection reset