Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-02 Thread Bruce Momjian
Manfred Spraul wrote: Tom Lane wrote: Not really: it only solves the problem *if you change the application*, which is IMHO not acceptable. In particular, why should a non-threaded app expect to have to change to deal with this issue? But we can't safely build a thread-safe libpq.so for

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-02 Thread Tom Lane
Manfred Spraul [EMAIL PROTECTED] writes: Tom Lane wrote: Not really: it only solves the problem *if you change the application*, which is IMHO not acceptable. No. non-threaded apps do not need to change. The default is the old, 7.3 code: change the signal handler around the write calls.

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-02 Thread Bruce Momjian
Tom Lane wrote: Manfred Spraul [EMAIL PROTECTED] writes: Tom Lane wrote: Not really: it only solves the problem *if you change the application*, which is IMHO not acceptable. No. non-threaded apps do not need to change. The default is the old, 7.3 code: change the signal handler

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-02 Thread Manfred Spraul
Tom Lane wrote: Not really: it only solves the problem *if you change the application*, which is IMHO not acceptable. In particular, why should a non-threaded app expect to have to change to deal with this issue? But we can't safely build a thread-safe libpq.so for general use if it breaks

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Bruce Momjian
Manfred Spraul wrote: Bruce Momjian wrote: Comments? This seems like our only solution. This would be a transparent solution. Another approach would be: - Use the old 7.3 approach by default. This means perfect backward compatibility for single-threaded apps and broken

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Oliver Jowett
Bruce Momjian wrote: [... SIGPIPE suppression in libpq ...] Linux also has MSG_NOSIGNAL as a send() flag that might be useful. It suppresses generation of SIGPIPE for just that call. No, it doesn't work for SSL and it's probably not very portable, but it might be a good platform-specific

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Tom Lane
Bruce Momjian [EMAIL PROTECTED] writes: His idea of pthread_sigmask/send/sigpending/sigwait/restore-mask. Seems we could also check errno for SIGPIPE rather than calling sigpending. He has a concern about an application that already blocked SIGPIPE and has a pending SIGPIPE signal waiting

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Manfred Spraul
Bruce Momjian wrote: Comments? This seems like our only solution. This would be a transparent solution. Another approach would be: - Use the old 7.3 approach by default. This means perfect backward compatibility for single-threaded apps and broken multithreaded apps. - Add a new PQinitDB(int

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Tom Lane
Manfred Spraul [EMAIL PROTECTED] writes: Is that really worthwhile? There are half a dozend assumption about the C library and kernel internal efficiency of the signal handling functions in the proposal. Adding a PQinitLib function is obviously a larger change, but it solves the problem.

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Bruce Momjian
Tom Lane wrote: Bruce Momjian [EMAIL PROTECTED] writes: His idea of pthread_sigmask/send/sigpending/sigwait/restore-mask. Seems we could also check errno for SIGPIPE rather than calling sigpending. He has a concern about an application that already blocked SIGPIPE and has a pending

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Bruce Momjian
Manfred Spraul wrote: This seems workable as long as we document the possible gotchas. Is that really worthwhile? There are half a dozend assumption about the C library and kernel internal efficiency of the signal handling functions in the proposal. Adding a PQinitLib function is

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Oliver Jowett
Tom Lane wrote: If the C library does support queued signals then we will read the existing SIGPIPE condition and leave our own signal in the queue. This is no problem to the extent that one pending SIGPIPE looks just like another --- does anyone know of platforms where there is additional info

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Tom Lane
Bruce Momjian [EMAIL PROTECTED] writes: Yes, that is the logic in my patch, except that I don't check errno, I just call sigpending(). No, that's wrong: if there is a pending SIGPIPE that belongs to the outer app, you'd clear it. There are a few writes and it seemed impossible to check them

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-12-01 Thread Manfred Spraul
Tom Lane wrote: Bruce Momjian [EMAIL PROTECTED] writes: His idea of pthread_sigmask/send/sigpending/sigwait/restore-mask. Seems we could also check errno for SIGPIPE rather than calling sigpending. He has a concern about an application that already blocked SIGPIPE and has a pending

Re: [HACKERS] libpq and psql not on same page about SIGPIPE

2004-11-30 Thread Bruce Momjian
Tom Lane wrote: libpq compiled with --enable-thread-safety thinks it can set the SIGPIPE signal handler. It thinks once is enough. psql thinks it can arbitrarily flip the signal handler between SIG_IGN and SIG_DFL. Ergo, after the first use of the pager for output, libpq's SIGPIPE

[HACKERS] libpq and psql not on same page about SIGPIPE

2004-11-15 Thread Tom Lane
libpq compiled with --enable-thread-safety thinks it can set the SIGPIPE signal handler. It thinks once is enough. psql thinks it can arbitrarily flip the signal handler between SIG_IGN and SIG_DFL. Ergo, after the first use of the pager for output, libpq's SIGPIPE handling will be broken. I