BUG #1467: fe_connect doesn't handle EINTR right - Mailing list pgsql-bugs

From Florian Hars
Subject BUG #1467: fe_connect doesn't handle EINTR right
Date
Msg-id 20050207120613.4DDB0F0B01@svr2.postgresql.org
Whole thread Raw
Responses Re: BUG #1467: fe_connect doesn't handle EINTR right  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      1467
Logged by:          Florian Hars
Email address:      hars@bik-gmbh.de
PostgreSQL version: 8.0.1
Operating system:   All
Description:        fe_connect doesn't handle EINTR right
Details:

The file pgsql/src/interfaces/libpq/fe-connect.c contains the code fragment

retry_connect:
  if (connect(conn->sock, addr_cur->ai_addr,
                      addr_cur->ai_addrlen) < 0)
  {
    if (SOCK_ERRNO == EINTR)
    /* Interrupted system call - just try again */
        goto retry_connect;
  }

This is not in accordance with a strict legalistic reading of the POSIX
spec, according to which connect is not restartable so that you have to use
select or poll after connect returned with EINTR.

See
http://www.eleves.ens.fr:8080/home/madore/computers/connect-intr.html
for the ugly details, your code should work on Linux, but not on Solaris or
(Free|Open)BSD.

pgsql-bugs by date:

Previous
From: "Joe Brown"
Date:
Subject: BUG #1466: #maintenace_work_mem = 16384
Next
From: Rolf Sponsel
Date:
Subject: Re: [Feed-back] Installing PostgreSQL 8.0.0 on SPARC/Solaris.