PostgreSQL Source Code  git master
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(*cancel_callback)(void))
 

Variables

volatile sig_atomic_t CancelRequested
 

Function Documentation

◆ ResetCancelConn()

void ResetCancelConn ( void  )

Definition at line 100 of file cancel.c.

References cancelConn, and PQfreeCancel().

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

101 {
102  PGcancel *oldCancelConn;
103 
104 #ifdef WIN32
105  EnterCriticalSection(&cancelConnLock);
106 #endif
107 
108  oldCancelConn = cancelConn;
109 
110  /* be sure handle_sigint doesn't use pointer while freeing */
111  cancelConn = NULL;
112 
113  if (oldCancelConn != NULL)
114  PQfreeCancel(oldCancelConn);
115 
116 #ifdef WIN32
117  LeaveCriticalSection(&cancelConnLock);
118 #endif
119 }
void PQfreeCancel(PGcancel *cancel)
Definition: fe-connect.c:4318
static PGcancel *volatile cancelConn
Definition: cancel.c:43

◆ SetCancelConn()

void SetCancelConn ( PGconn conn)

Definition at line 70 of file cancel.c.

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

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

71 {
72  PGcancel *oldCancelConn;
73 
74 #ifdef WIN32
75  EnterCriticalSection(&cancelConnLock);
76 #endif
77 
78  /* Free the old one if we have one */
79  oldCancelConn = cancelConn;
80 
81  /* be sure handle_sigint doesn't use pointer while freeing */
82  cancelConn = NULL;
83 
84  if (oldCancelConn != NULL)
85  PQfreeCancel(oldCancelConn);
86 
87  cancelConn = PQgetCancel(conn);
88 
89 #ifdef WIN32
90  LeaveCriticalSection(&cancelConnLock);
91 #endif
92 }
void PQfreeCancel(PGcancel *cancel)
Definition: fe-connect.c:4318
PGcancel * PQgetCancel(PGconn *conn)
Definition: fe-connect.c:4295
static PGcancel *volatile cancelConn
Definition: cancel.c:43

◆ setup_cancel_handler()

void setup_cancel_handler ( void(*)(void)  cancel_callback)

Definition at line 179 of file cancel.c.

References _, callback(), cancel_callback, CancelRequested, handle_sigint(), PQcancel(), pqsignal(), setup_cancel_handler(), and write_stderr.

Referenced by setup_cancel_handler().

180 {
182  pqsignal(SIGINT, handle_sigint);
183 }
static void(* cancel_callback)(void)
Definition: cancel.c:61
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:170
static void handle_sigint(SIGNAL_ARGS)
Definition: cancel.c:146

Variable Documentation

◆ CancelRequested

volatile sig_atomic_t CancelRequested