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.
This commit is contained in:
Tom Lane 2003-02-01 00:07:03 +00:00
parent f51c7ca182
commit 032235cafe
1 changed files with 11 additions and 9 deletions

View File

@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.38 2002/12/30 22:10:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.39 2003/02/01 00:07:03 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -295,17 +295,19 @@ PgDelConnectionId(DRIVER_DEL_PROTO)
* the socket itself! * the socket itself!
* *
* XXX Unfortunately, while this works fine if we are closing due to * 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 * explicit pg_disconnect, all Tcl versions through 8.4.1 dump core
* try to do it during interpreter shutdown. Not clear why, or if * if we try to do it during interpreter shutdown. Not clear why.
* there is a workaround. For now, accept leakage of the (fairly * For now, we kill the channel during pg_disconnect, but during interp
* small) amount of memory taken for the channel state representation. * shutdown we just accept leakage of the (fairly small) amount of memory
* Note we are not leaking a socket, since libpq closed that already. * 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 TCL_MAJOR_VERSION >= 8
if (connid->notifier_channel != NULL) if (connid->notifier_channel != NULL && interp != NULL)
Tcl_UnregisterChannel(NULL, connid->notifier_channel); Tcl_UnregisterChannel(NULL, connid->notifier_channel);
#endif
#endif #endif
/* /*