diff options
| author | Tom Lane | 2000-12-18 17:33:42 +0000 |
|---|---|---|
| committer | Tom Lane | 2000-12-18 17:33:42 +0000 |
| commit | 5491233f5245c464be2286ad894448b21ef757db (patch) | |
| tree | 8badaae022de82ec4cd53ffe42e2c22e681c394d /src/interfaces | |
| parent | c431db9714bfca24f05fd301ae2f027f83689e4f (diff) | |
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.
Diffstat (limited to 'src/interfaces')
| -rw-r--r-- | src/interfaces/libpq/fe-connect.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index c95ee99b94f..868b73f6f7c 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.154 2000/12/07 02:04:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.155 2000/12/18 17:33:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2084,6 +2084,7 @@ PQresetPoll(PGconn *conn) * malloc/free are often non-reentrant, and anything that might call them is * just as dangerous. We avoid sprintf here for that reason. Building up * error messages with strcpy/strcat is tedious but should be quite safe. + * We also save/restore errno in case the signal handler support doesn't. * * NOTE: this routine must not generate any error message longer than * INITIAL_EXPBUFFER_SIZE (currently 256), since we dare not try to @@ -2093,6 +2094,7 @@ PQresetPoll(PGconn *conn) int PQrequestCancel(PGconn *conn) { + int save_errno = errno; int tmpsock = -1; struct { @@ -2109,6 +2111,7 @@ PQrequestCancel(PGconn *conn) strcpy(conn->errorMessage.data, "PQrequestCancel() -- connection is not open\n"); conn->errorMessage.len = strlen(conn->errorMessage.data); + errno = save_errno; return FALSE; } @@ -2154,6 +2157,7 @@ PQrequestCancel(PGconn *conn) close(tmpsock); #endif + errno = save_errno; return TRUE; cancel_errReturn: @@ -2168,6 +2172,7 @@ cancel_errReturn: close(tmpsock); #endif } + errno = save_errno; return FALSE; } |
