Re: message type 0x50 - Mailing list pgsql-general

From Greg Stark
Subject Re: message type 0x50
Date
Msg-id 87r82o1qco.fsf@stark.dyndns.tv
Whole thread Raw
In response to message type 0x50  (Alessandro GARDICH <gremlin@gremlin.it>)
List pgsql-general
Alessandro GARDICH <gremlin@gremlin.it> writes:

> the program is quite simple, a loop do UPDATE on a random entry on a
> table. Server is without autocommit.
>
> with setittimer and SIGALRM i do an explicit COMMIT every 10 seconds,
> update loop have a random delay from 0 to 500 msec using usleep().

I don't know the full answer to your question, but I don't think it's safe to
call libpq functions from signals handlers. It's not really safe to do much of
anything in signal handlers in fact. Even functions like printf() and malloc()
aren't technically safe to call from signal handlers.

What you should probably do is set a flag that you check upon completion of
the usleep() or after every update, and handle the commit there.

--
greg

pgsql-general by date:

Previous
From: "D. Stimits"
Date:
Subject: Re: C API, PQconnectdb and options Q.
Next
From: Brian Hirt
Date:
Subject: Re: Picture with Postgres and Delphi