mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
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.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.15 1998/02/26 04:31:56 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.16 1998/07/09 03:28:46 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -33,7 +33,7 @@
|
||||
* Set up a packet read for the postmaster event loop.
|
||||
*/
|
||||
|
||||
void PacketReceiveSetup(Packet *pkt, void (*iodone) (), char *arg)
|
||||
void PacketReceiveSetup(Packet *pkt, PacketDoneProc iodone, void *arg)
|
||||
{
|
||||
pkt->nrtodo = sizeof(pkt->len);
|
||||
pkt->ptr = (char *) &pkt->len;
|
||||
@ -94,8 +94,8 @@ PacketReceiveFragment(Packet *pkt, int sock)
|
||||
if (pkt->iodone == NULL)
|
||||
return STATUS_ERROR;
|
||||
|
||||
(*pkt->iodone) (pkt->arg, pkt->len - sizeof(pkt->len),
|
||||
(char *) &pkt->pkt);
|
||||
return (*pkt->iodone) (pkt->arg, pkt->len - sizeof(pkt->len),
|
||||
(void *) &pkt->pkt);
|
||||
}
|
||||
|
||||
return STATUS_OK;
|
||||
@ -107,7 +107,7 @@ PacketReceiveFragment(Packet *pkt, int sock)
|
||||
if (errno == EINTR)
|
||||
return STATUS_OK;
|
||||
|
||||
fprintf(stderr, "read() system call failed\n");
|
||||
perror("PacketReceiveFragment: read() failed");
|
||||
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@ -117,8 +117,9 @@ PacketReceiveFragment(Packet *pkt, int sock)
|
||||
* Set up a packet write for the postmaster event loop.
|
||||
*/
|
||||
|
||||
void PacketSendSetup(Packet *pkt, int nbytes, void (*iodone) (), char *arg)
|
||||
void PacketSendSetup(Packet *pkt, int nbytes, PacketDoneProc iodone, void *arg)
|
||||
{
|
||||
pkt->len = (PacketLen) nbytes;
|
||||
pkt->nrtodo = nbytes;
|
||||
pkt->ptr = (char *) &pkt->pkt;
|
||||
pkt->iodone = iodone;
|
||||
@ -153,7 +154,8 @@ PacketSendFragment(Packet *pkt, int sock)
|
||||
if (pkt->iodone == NULL)
|
||||
return STATUS_ERROR;
|
||||
|
||||
(*pkt->iodone) (pkt->arg);
|
||||
return (*pkt->iodone) (pkt->arg, pkt->len,
|
||||
(void *) &pkt->pkt);
|
||||
}
|
||||
|
||||
return STATUS_OK;
|
||||
@ -165,7 +167,7 @@ PacketSendFragment(Packet *pkt, int sock)
|
||||
if (errno == EINTR)
|
||||
return STATUS_OK;
|
||||
|
||||
fprintf(stderr, "write() system call failed\n");
|
||||
perror("PacketSendFragment: write() failed");
|
||||
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
Reference in New Issue
Block a user