aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpgtcl/pgtclId.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1998-08-22 04:34:22 +0000
committerBruce Momjian <bruce@momjian.us>1998-08-22 04:34:22 +0000
commitc0d730460fc93ae83a50a5375b843ccb9b020e66 (patch)
treef0997b7a765e3fd08fd8972587b683545eeb91ca /src/interfaces/libpgtcl/pgtclId.c
parenta738478ad8319bb4761dc53dfe700cb1fe87000e (diff)
downloadpostgresql-c0d730460fc93ae83a50a5375b843ccb9b020e66.tar.gz
postgresql-c0d730460fc93ae83a50a5375b843ccb9b020e66.zip
The attached patch fixes a problem that I seem to have introduced
with the new support for asynchronous NOTIFY in libpgtcl. With the current sources, if the backend disconnects unexpectedly then the tcl/tk application coredumps when control next reaches the idle loop. Oops. regards, tom lane
Diffstat (limited to 'src/interfaces/libpgtcl/pgtclId.c')
-rw-r--r--src/interfaces/libpgtcl/pgtclId.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c
index 05dfb19b6de..1d3cd29709a 100644
--- a/src/interfaces/libpgtcl/pgtclId.c
+++ b/src/interfaces/libpgtcl/pgtclId.c
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.12 1998/08/17 03:50:26 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.13 1998/08/22 04:34:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -475,6 +475,7 @@ static void Pg_Notify_SetupProc (ClientData clientData, int flags)
{
Pg_ConnectionId *connid = (Pg_ConnectionId *) clientData;
Tcl_File handle;
+ int pqsock;
/* We classify SQL notifies as Tcl file events. */
if (!(flags & TCL_FILE_EVENTS)) {
@@ -482,7 +483,11 @@ static void Pg_Notify_SetupProc (ClientData clientData, int flags)
}
/* Set up to watch for asynchronous data arrival on backend channel */
- handle = Tcl_GetFile((ClientData) PQsocket(connid->conn), TCL_UNIX_FD);
+ pqsock = PQsocket(connid->conn);
+ if (pqsock < 0)
+ return;
+
+ handle = Tcl_GetFile((ClientData) pqsock, TCL_UNIX_FD);
Tcl_WatchFile(handle, TCL_READABLE);
}
@@ -492,6 +497,7 @@ static void Pg_Notify_CheckProc (ClientData clientData, int flags)
{
Pg_ConnectionId *connid = (Pg_ConnectionId *) clientData;
Tcl_File handle;
+ int pqsock;
/* We classify SQL notifies as Tcl file events. */
if (!(flags & TCL_FILE_EVENTS)) {
@@ -503,7 +509,11 @@ static void Pg_Notify_CheckProc (ClientData clientData, int flags)
* We use Tcl_FileReady to avoid a useless kernel call
* when no data is available.
*/
- handle = Tcl_GetFile((ClientData) PQsocket(connid->conn), TCL_UNIX_FD);
+ pqsock = PQsocket(connid->conn);
+ if (pqsock < 0)
+ return;
+
+ handle = Tcl_GetFile((ClientData) pqsock, TCL_UNIX_FD);
if (Tcl_FileReady(handle, TCL_READABLE) != 0) {
PQconsumeInput(connid->conn);
}