From 6d8476ab3b367e42fa2e6ea809aa27fa265ad9db Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 4 Nov 2005 18:35:51 +0000 Subject: [PATCH] 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. --- src/bin/psql/common.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 1c26eb6b84..c98322ca4c 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -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" @@ -315,7 +315,14 @@ setup_win32_locks(void) void setup_cancel_handler(void) { - SetConsoleCtrlHandler(consoleHandler, TRUE); + static bool done = false; + + /* only need one handler per process */ + if (!done) + { + SetConsoleCtrlHandler(consoleHandler, TRUE); + done = true; + } } #endif /* WIN32 */