PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cancel.h File Reference
#include <signal.h>
#include "libpq-fe.h"
Include dependency graph for cancel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void SetCancelConn (PGconn *conn)
 
void ResetCancelConn (void)
 
void setup_cancel_handler (void(*query_cancel_callback)(void))
 

Variables

PGDLLIMPORT volatile sig_atomic_t CancelRequested
 

Function Documentation

◆ ResetCancelConn()

void ResetCancelConn ( void  )

Definition at line 107 of file cancel.c.

108 {
109  PGcancel *oldCancelConn;
110 
111 #ifdef WIN32
112  EnterCriticalSection(&cancelConnLock);
113 #endif
114 
115  oldCancelConn = cancelConn;
116 
117  /* be sure handle_sigint doesn't use pointer while freeing */
118  cancelConn = NULL;
119 
120  if (oldCancelConn != NULL)
121  PQfreeCancel(oldCancelConn);
122 
123 #ifdef WIN32
124  LeaveCriticalSection(&cancelConnLock);
125 #endif
126 }
static PGcancel *volatile cancelConn
Definition: cancel.c:43
void PQfreeCancel(PGcancel *cancel)
Definition: fe-cancel.c:417

References cancelConn, and PQfreeCancel().

Referenced by CheckConnection(), consumeQueryResult(), do_connect(), do_lo_export(), do_lo_import(), do_lo_unlink(), executeMaintenanceCommand(), HandleCopyResult(), PSQLexec(), PSQLexecWatch(), runInitSteps(), SendQuery(), and wait_on_slots().

◆ SetCancelConn()

void SetCancelConn ( PGconn conn)

Definition at line 77 of file cancel.c.

78 {
79  PGcancel *oldCancelConn;
80 
81 #ifdef WIN32
82  EnterCriticalSection(&cancelConnLock);
83 #endif
84 
85  /* Free the old one if we have one */
86  oldCancelConn = cancelConn;
87 
88  /* be sure handle_sigint doesn't use pointer while freeing */
89  cancelConn = NULL;
90 
91  if (oldCancelConn != NULL)
92  PQfreeCancel(oldCancelConn);
93 
95 
96 #ifdef WIN32
97  LeaveCriticalSection(&cancelConnLock);
98 #endif
99 }
PGcancel * PQgetCancel(PGconn *conn)
Definition: fe-cancel.c:349
PGconn * conn
Definition: streamutil.c:53

References cancelConn, conn, PQfreeCancel(), and PQgetCancel().

Referenced by consumeQueryResult(), do_lo_export(), do_lo_import(), do_lo_unlink(), executeMaintenanceCommand(), HandleCopyResult(), PSQLexec(), PSQLexecWatch(), runInitSteps(), SendQuery(), and wait_on_slots().

◆ setup_cancel_handler()

void setup_cancel_handler ( void(*)(void)  query_cancel_callback)

Definition at line 183 of file cancel.c.

184 {
185  cancel_callback = query_cancel_callback;
186  cancel_sent_msg = _("Cancel request sent\n");
187  cancel_not_sent_msg = _("Could not send cancel request: ");
188 
189  pqsignal(SIGINT, handle_sigint);
190 }
static void(* cancel_callback)(void)
Definition: cancel.c:68
static const char * cancel_sent_msg
Definition: cancel.c:49
static const char * cancel_not_sent_msg
Definition: cancel.c:50
static void handle_sigint(SIGNAL_ARGS)
Definition: cancel.c:153
#define _(x)
Definition: elog.c:90
pqsigfunc pqsignal(int signo, pqsigfunc func)

References _, cancel_callback, cancel_not_sent_msg, cancel_sent_msg, handle_sigint(), and pqsignal().

Referenced by main(), psql_setup_cancel_handler(), and runInitSteps().

Variable Documentation

◆ CancelRequested

PGDLLIMPORT volatile sig_atomic_t CancelRequested
extern