Re: [PATCHES] SIGPIPE handling, take two.

2003-11-11 Thread Tom Lane
Manfred Spraul <[EMAIL PROTECTED]> writes: > ... But the SIG_IGN/restore > sequence affects the whole app - PQconnectdb calls would result in > randomly dropped SIGPIPE signals. Good point. AFAICS we lose anyway if we don't have sigaction() available, but hopefully any multithreaded platform ha

Re: [PATCHES] SIGPIPE handling, take two.

2003-11-11 Thread Manfred Spraul
Tom Lane wrote: I don't think we need to complicate pqsignal's API for this. Instead we'd better document that SIGPIPE handling has to be set up and kept stable before doing any libpq operations in a multithread app. Not reliable. An app could install it's own signal handler and block SIGPIPE

Re: [PATCHES] SIGPIPE handling, take two.

2003-11-11 Thread Tom Lane
Manfred Spraul <[EMAIL PROTECTED]> writes: > What about multithreaded apps? > old = pgsignal(SIPEPIPE, SIG_IGN); > ** another thread calls sigaction(SIGPIPE,,); > pgsignal(SIGPIPE, old); > And the signal state is corrupted. If other threads are changing the signal state mid-flight, we are

Re: [PATCHES] SIGPIPE handling, take two.

2003-11-11 Thread Manfred Spraul
Tom Lane wrote: Bruce Momjian <[EMAIL PROTECTED]> writes: I think this is the patch I like. The #if coding is messy and unnecessary. You could do the test as per the non-POSIX variant using two calls of pqsignal(), and not have any system dependence here, nor a need for . What about mu

Re: [PATCHES] SIGPIPE handling, take two.

2003-11-11 Thread Tom Lane
Oh, forgot to mention ... Bruce Momjian <[EMAIL PROTECTED]> writes: > My only issue is that this is per-connection, while I think you have to > create a global variable that defaults to false, and on first connect, > check, and not after. No, because this patch does not have any global effect on

Re: [PATCHES] SIGPIPE handling, take two.

2003-11-11 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > I think this is the patch I like. The #if coding is messy and unnecessary. You could do the test as per the non-POSIX variant using two calls of pqsignal(), and not have any system dependence here, nor a need for . regards, tom

Re: [PATCHES] SIGPIPE handling, take two.

2003-11-11 Thread Gaetano Mendola
Gaetano Mendola wrote: Bruce Momjian wrote: I think this is the patch I like. It does the auto-detect handling as I hoped. I will just do the doc updates to mention it. My only issue is that this is per-connection, while I think you have to create a global variable that defaults to false, and o

Re: [PATCHES] SIGPIPE handling, take two.

2003-11-11 Thread Gaetano Mendola
Bruce Momjian wrote: I think this is the patch I like. It does the auto-detect handling as I hoped. I will just do the doc updates to mention it. My only issue is that this is per-connection, while I think you have to create a global variable that defaults to false, and on first connect, check, a

Re: [PATCHES] SIGPIPE handling, take two.

2003-11-10 Thread Bruce Momjian
I think this is the patch I like. It does the auto-detect handling as I hoped. I will just do the doc updates to mention it. My only issue is that this is per-connection, while I think you have to create a global variable that defaults to false, and on first connect, check, and not after. Base

[PATCHES] SIGPIPE handling, take two.

2003-11-02 Thread Manfred Spraul
pqsecure_write tries to catch SIGPIPE signals generated by network disconnects by setting the signal handler to SIG_IGN. The current approach causes several problems: - it always sets SA_RESTART when it restores the old handler. - it's not reliable for multi threaded apps, because another thread