Ensure that we only create one ConsoleCtrlHandler per psql process,

so as to avoid performance issues and possible ultimate crash on long
psql scripts.  Per Merlin Moncure.
This commit is contained in:
Tom Lane 2005-11-04 18:35:51 +00:00
parent 0c1a3f94c6
commit 6d8476ab3b

View File

@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.95 2005/01/01 05:43:08 momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.95.4.1 2005/11/04 18:35:51 tgl Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@ -314,8 +314,15 @@ setup_win32_locks(void)
void
setup_cancel_handler(void)
{
static bool done = false;
/* only need one handler per process */
if (!done)
{
SetConsoleCtrlHandler(consoleHandler, TRUE);
done = true;
}
}
#endif /* WIN32 */