Re: [patch] helps fe-connect.c handle -EINTR more gracefully

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Ford <david(at)blue-labs(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [patch] helps fe-connect.c handle -EINTR more gracefully
Date: 2001-10-27 01:43:32
Message-ID: 29805.1004147012@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Actually, now that I look at this another time, there's an interesting
question to ask: have you compiled with USE_SSL?

The USE_SSL case definitely is broken, since it invokes the connect()
in blocking mode, but fails to retry on EINTR, which it clearly should
do in that mode. (What's even worse is that you cannot suppress
the problem by setting allow_ssl_try false. If you compiled with SSL
support enabled then you lose anyway.)

I think we can fix this by moving the SSL startup code to a saner place,
namely in PQconnectPoll just before it's about to send the startup
packet. There's no reason why we shouldn't *always* do the connect()
in nonblock mode. We could switch the socket back to blocking mode
while invoking the SSL negotiation phase (which'd be skipped if not
allow_ssl_try, so that a library compiled with USE_SSL isn't ipso
facto broken for people who want non-SSL nonblocking connect).

If you are testing with USE_SSL then that explains why you are seeing
EINTR failures. If not, then we still have to ask whether EINTR really
needs to be handled differently from EINPROGRESS.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Ford 2001-10-27 02:08:05 Re: [patch] helps fe-connect.c handle -EINTR more gracefully
Previous Message Bruce Momjian 2001-10-27 01:38:40 Re: 7.2b1 ...