Re: message type 0x50

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: message type 0x50
Date: 2003-09-10 17:54:31
Message-ID: 87r82o1qco.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alessandro GARDICH <gremlin(at)gremlin(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brian Hirt 2003-09-10 17:56:52 Re: Picture with Postgres and Delphi
Previous Message D. Stimits 2003-09-10 17:47:51 Re: C API, PQconnectdb and options Q.