mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Clean up psql's control-C handling to avoid longjmp'ing out of random
places --- that risks corrupting data structures, losing sync with the backend, etc. We now longjmp only from calls to readline, fgets, and fread, which we assume are coded to protect themselves against interrupts at undesirable times. This requires adding explicit tests for cancel_pressed in long-running loops, but on the whole it's far cleaner. Martijn van Oosterhout and Tom Lane.
This commit is contained in:
@@ -3,14 +3,13 @@
|
||||
*
|
||||
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.49 2006/06/01 00:15:36 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.50 2006/06/14 16:49:02 tgl Exp $
|
||||
*/
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include "postgres_fe.h"
|
||||
#include <signal.h>
|
||||
#include "pqsignal.h"
|
||||
#include <setjmp.h>
|
||||
#include "libpq-fe.h"
|
||||
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
@@ -41,16 +40,17 @@ __attribute__((format(printf, 1, 2)));
|
||||
|
||||
extern void NoticeProcessor(void *arg, const char *message);
|
||||
|
||||
extern volatile bool sigint_interrupt_enabled;
|
||||
|
||||
extern sigjmp_buf sigint_interrupt_jmp;
|
||||
|
||||
extern volatile bool cancel_pressed;
|
||||
/* Note: cancel_pressed is defined in print.c, see that file for reasons */
|
||||
|
||||
extern void ResetCancelConn(void);
|
||||
|
||||
#ifndef WIN32
|
||||
extern void handle_sigint(SIGNAL_ARGS);
|
||||
#else
|
||||
extern void setup_win32_locks(void);
|
||||
extern void setup_cancel_handler(void);
|
||||
#endif
|
||||
|
||||
extern void SetCancelConn(void);
|
||||
extern void ResetCancelConn(void);
|
||||
|
||||
extern PGresult *PSQLexec(const char *query, bool start_xact);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user