diff options
author | Marc G. Fournier <scrappy@hub.org> | 1998-07-09 03:29:11 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 1998-07-09 03:29:11 +0000 |
commit | a0659e3e2c79be49feb4aa527d823c71d7bcaf07 (patch) | |
tree | 7dc58e872cdfce999dd0848000fcd3f2e4edbafa /src/interfaces/libpq/fe-exec.c | |
parent | 8bf61820f033d7df0e89433a0272d7b2567378b8 (diff) |
From: Tom Lane <tgl@sss.pgh.pa.us>
Making PQrequestCancel safe to call in a signal handler turned out to be
much easier than I feared. So here are the diffs.
Some notes:
* I modified the postmaster's packet "iodone" callback interface to allow
the callback routine to return a continue-or-drop-connection return
code; this was necessary to allow the connection to be closed after
receiving a Cancel, rather than proceeding to launch a new backend...
Being a neatnik, I also made the iodone proc have a typechecked
parameter list.
* I deleted all code I could find that had to do with OOB.
* I made some edits to ensure that all signals mentioned in the code
are referred to symbolically not by numbers ("SIGUSR2" not "2").
I think Bruce may have already done at least some of the same edits;
I hope that merging these patches is not too painful.
Diffstat (limited to 'src/interfaces/libpq/fe-exec.c')
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 49bd6d07e51..6a68af49d3e 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.55 1998/07/03 04:24:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.56 1998/07/09 03:29:08 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -361,6 +361,16 @@ parseInput(PGconn *conn) PGRES_EMPTY_QUERY); conn->asyncStatus = PGASYNC_READY; break; + case 'K': /* secret key data from the backend */ + /* This is expected only during backend startup, + * but it's just as easy to handle it as part of the + * main loop. Save the data and continue processing. + */ + if (pqGetInt(&(conn->be_pid), 4, conn)) + return; + if (pqGetInt(&(conn->be_key), 4, conn)) + return; + break; case 'N': /* notices from the backend */ if (getNotice(conn)) return; @@ -762,44 +772,6 @@ PQexec(PGconn *conn, const char *query) /* - * Attempt to request cancellation of the current operation. - * - * The return value is TRUE if the cancel request was successfully - * dispatched, FALSE if not (in which case errorMessage is set). - * Note: successful dispatch is no guarantee that there will be any effect at - * the backend. The application must read the operation result as usual. - */ - -int -PQrequestCancel(PGconn *conn) -{ - char msg[1]; - - if (!conn) - return FALSE; - - if (conn->sock < 0) - { - sprintf(conn->errorMessage, - "PQrequestCancel() -- connection is not open\n"); - return FALSE; - } - - msg[0] = '\0'; - - if (send(conn->sock, msg, 1, MSG_OOB) < 0) - { - sprintf(conn->errorMessage, - "PQrequestCancel() -- couldn't send OOB data: errno=%d\n%s\n", - errno, strerror(errno)); - return FALSE; - } - - return TRUE; -} - - -/* * Attempt to read a Notice response message. * This is possible in several places, so we break it out as a subroutine. * Entry: 'N' flag character has already been consumed. |