summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2003-02-01 00:07:19 +0000
committerTom Lane2003-02-01 00:07:19 +0000
commita85d1d546846b30b6c7b439be253bb188d8574bc (patch)
tree2f65a52e87070c737937d525cd66ffafc74c9925
parentc8d7686c70f78bf85ea38bc16394f3fa05c14f3f (diff)
Apply ljb's patch to prevent both memory leak and core dump during
connection shutdown. This is a grotty workaround for a Tcl bug, but said bug has been there long enough that I'm not holding my breath for a real fix. Per discussions and testing from ljb and g.hintermayer.
-rw-r--r--src/interfaces/libpgtcl/pgtclId.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c
index cc79339c6be..56fd72754f9 100644
--- a/src/interfaces/libpgtcl/pgtclId.c
+++ b/src/interfaces/libpgtcl/pgtclId.c
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.37 2002/10/17 14:53:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.37.2.1 2003/02/01 00:07:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -294,18 +294,20 @@ PgDelConnectionId(DRIVER_DEL_PROTO)
* the socket itself!
*
* XXX Unfortunately, while this works fine if we are closing due to
- * explicit pg_disconnect, Tcl versions through 8.3.3 dump core if we
- * try to do it during interpreter shutdown. Not clear why, or if
- * there is a workaround. For now, accept leakage of the (fairly
- * small) amount of memory taken for the channel state representation.
- * Note we are not leaking a socket, since libpq closed that already.
+ * explicit pg_disconnect, all Tcl versions through 8.4.1 dump core
+ * if we try to do it during interpreter shutdown. Not clear why.
+ * For now, we kill the channel during pg_disconnect, but during interp
+ * shutdown we just accept leakage of the (fairly small) amount of memory
+ * taken for the channel state representation.
+ * (Note we are not leaking a socket, since libpq closed that already.)
+ * We tell the difference between pg_disconnect and interpreter shutdown
+ * by testing for interp != NULL, which is an undocumented but apparently
+ * safe way to tell.
*/
-#ifdef NOT_USED
#if TCL_MAJOR_VERSION >= 8
- if (connid->notifier_channel != NULL)
+ if (connid->notifier_channel != NULL && interp != NULL)
Tcl_UnregisterChannel(NULL, connid->notifier_channel);
#endif
-#endif
/*
* We must use Tcl_EventuallyFree because we don't want the connid