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

2001-10-28 Thread Peter Eisentraut
Tom Lane writes: > AFAICT the client-side libpq doesn't (and shouldn't) touch signal > handling at all, except for a couple of places in the print routines > that temporarily block SIGPIPE. Which was my point. > Since we deal happily with EINTR for most of the frontend socket calls, > I don't s

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

2001-10-27 Thread Tom Lane
David Ford <[EMAIL PROTECTED]> writes: > I traced several calls and they run through a few functions which end > up in pqFlush. These code paths haven't checked the socket to see if it > is ready for RW operation yet. pqFlush calls send() [ignoring SSL]. Where? AFAICS (ignoring the USE_SSL

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

2001-10-26 Thread David Ford
> > > >I think you are missing the point. I am not saying that we shouldn't >deal with EINTR; rather I am raising what I think is a legitimate >question: *what* is the most appropriate response? My reading of >HP's gloss suggests that we could treat EINTR the same as EINPROGRESS, >ie, consider t

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

2001-10-26 Thread Tom Lane
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

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

2001-10-26 Thread Tom Lane
David Ford <[EMAIL PROTECTED]> writes: > [ much ] I think you are missing the point. I am not saying that we shouldn't deal with EINTR; rather I am raising what I think is a legitimate question: *what* is the most appropriate response? My reading of HP's gloss suggests that we could treat EINTR

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

2001-10-26 Thread David Ford
> > > >No, it should *not* look like that. The fe-connect.c code is designed >to move on as soon as it's convinced that the kernel has accepted the >connection request. We use a non-blocking connect() call and later >wait for connection complete by probing the select() status. Looping >on the c

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

2001-10-26 Thread David Ford
"The **SA_RESTART** flag is always set by the underlying system in POSIX mode so that interrupted system calls will fail with return value of -1 and the *EINTR* error in /errno/ instead of getting restarted." libpq's pqsignal.c doesn't turn off SA_RESTART for SIGALRM. Further, pqsignal.c on

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

2001-10-26 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > Libpq certainly does deal with system calls being interrupted: It does > not allow them to be interrupted. Take a look into the file pqsignal.c to > see why. ??? Are you momentarily confusing backend and frontend libpq? AFAICT the client-side lib

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

2001-10-26 Thread Tom Lane
David Ford <[EMAIL PROTECTED]> writes: > Thus a simplified loop should look like this: No, it should *not* look like that. The fe-connect.c code is designed to move on as soon as it's convinced that the kernel has accepted the connection request. We use a non-blocking connect() call and later w

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

2001-10-26 Thread Peter Eisentraut
David Ford writes: > Libpq doesn't deal with system calls being interrupted in the slightest. > None of the read/write or socket calls handle any errors. Even benign > returns i.e. EINTR are treated as fatal errors and returned. Not to > malign, but there is no reason not to continue on and ha

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

2001-10-26 Thread David Ford
> > >This does not actually *say* that the appropriate behavior after EINTR >is to retry, but reading between the lines one might infer that it will >work like the nonblocking case, wherein a retry of connect tries to link >to the existing connection attempt, not start a new one. > >What's more im

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

2001-10-26 Thread David Ford
> > >After further thought, though, it's unclear to me why this solves >David's problem. If he's got a repeating SIGALRM on a cycle short >enough to interrupt a connect(), seems like it'd just fail again >on the next try. > Ok, a few things. The connect() call is just an interface to the kerne

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

2001-10-26 Thread Tom Lane
David Ford <[EMAIL PROTECTED]> writes: > Please wait a day before applying the patch, I want to make it a bit > more clean/readable and make sure I covered everything in fe-connect.c, BTW, reading the HPUX man page for connect I find the following relevant error codes: [EALREADY]

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

2001-10-26 Thread Tom Lane
Brent Verner <[EMAIL PROTECTED]> writes: > | Unless someone can point out a situation where retrying connect() > | after EINTR is actively bad, my inclination is to accept the patch. > I've found numerous examples where connect() is retried after EINTR, > infact it appears to be fairly common.

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

2001-10-25 Thread Brent Verner
On 26 Oct 2001 at 00:05 (-0400), Tom Lane wrote: | Brent Verner <[EMAIL PROTECTED]> writes: | > I'm not sure this is correct. I've tried to /make/ a SIGALRM cause | > connect to errno==EINTR, but I can't cause this condition. | | It wouldn't surprise me in the least if this behavior is | platfor

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

2001-10-25 Thread David Ford
> > > >It wouldn't surprise me in the least if this behavior is >platform-dependent. It may well be that David's kernel will allow >connect() to be interrupted by SIGALRM while yours won't. (Which >reminds me that neither of you specified what platforms you were >testing on. For shame.) Or may

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

2001-10-25 Thread David Ford
Many signals may be the cause of -EINTR. It depends on what the signal is as to how it's normally handled. sigalarm is the most common due to it being a timer event. Generate a timer that expires as fast as possible (not too fast to prevent code execution), and you should see things left and

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

2001-10-25 Thread Tom Lane
Brent Verner <[EMAIL PROTECTED]> writes: > I'm not sure this is correct. I've tried to /make/ a SIGALRM cause > connect to errno==EINTR, but I can't cause this condition. It wouldn't surprise me in the least if this behavior is platform-dependent. It may well be that David's kernel will allow c

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

2001-10-25 Thread Brent Verner
On 25 Oct 2001 at 17:08 (-0400), David Ford wrote: | I'm fresh in the code, but this has solved my issues with PQconnect* | failing when interrupted by signals. Some of it is sloppy and not to my | liking yet, but I'm still digging through to see if anything else needs | touched. Comments app

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

2001-10-25 Thread David Ford
I'm fresh in the code, but this has solved my issues with PQconnect* failing when interrupted by signals. Some of it is sloppy and not to my liking yet, but I'm still digging through to see if anything else needs touched. Comments appreciated. Honestly, I'm a bit surprised that this issue ha