Thread: pgsql/src/interfaces/libpq (fe-connect.c)

pgsql/src/interfaces/libpq (fe-connect.c)

From
tgl@postgresql.org
Date:
  Date: Monday, December 18, 2000 @ 12:33:42
Author: tgl

Update of /home/projects/pgsql/cvsroot/pgsql/src/interfaces/libpq
     from hub.org:/home/projects/pgsql/tmp/cvs-serv46276/src/interfaces/libpq

Modified Files:
    fe-connect.c

-----------------------------  Log Message  -----------------------------

Ensure that 'errno' is saved and restored by all signal handlers that
might change it.  Experimentation shows that the signal handler call
mechanism does not save/restore errno for you, at least not on Linux
or HPUX, so this is definitely a real risk.

Re: pgsql/src/interfaces/libpq (fe-connect.c)

From
Alfred Perlstein
Date:
* tgl@postgresql.org <tgl@postgresql.org> [001218 09:34] wrote:
>   Date: Monday, December 18, 2000 @ 12:33:42
> Author: tgl
>
> Update of /home/projects/pgsql/cvsroot/pgsql/src/interfaces/libpq
>      from hub.org:/home/projects/pgsql/tmp/cvs-serv46276/src/interfaces/libpq
>
> Modified Files:
>     fe-connect.c
>
> -----------------------------  Log Message  -----------------------------
>
> Ensure that 'errno' is saved and restored by all signal handlers that
> might change it.  Experimentation shows that the signal handler call
> mechanism does not save/restore errno for you, at least not on Linux
> or HPUX, so this is definitely a real risk.

I'm not sure why you're doing this, if someone calls PQrequestCancel,
they shouldn't expect it to preserve errno.

Afaik you're not responcible for saving/restoring errno on all
entries to a userland library, users should know to check beforehand.

--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."

Re: pgsql/src/interfaces/libpq (fe-connect.c)

From
Tom Lane
Date:
Alfred Perlstein <bright@wintelcom.net> writes:
>> Ensure that 'errno' is saved and restored by all signal handlers that
>> might change it.

> I'm not sure why you're doing this, if someone calls PQrequestCancel,
> they shouldn't expect it to preserve errno.

PQrequestCancel is designed and documented to be callable from user
signal handlers, so it seems like good defensive programming to make
it save/restore errno.

            regards, tom lane