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

Started by Tom Laneover 25 years ago3 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

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.

#2Alfred Perlstein
bright@wintelcom.net
In reply to: Tom Lane (#1)
Re: pgsql/src/interfaces/libpq (fe-connect.c)

* 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."

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alfred Perlstein (#2)
Re: pgsql/src/interfaces/libpq (fe-connect.c)

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