8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.60 2008/04/15 13:55:11 momjian Exp $
11
+ * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.61 2008/04/15 20:28:46 momjian Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
27
27
#include "postmaster/syslogger.h"
28
28
#include "storage/fd.h"
29
29
#include "storage/pmsignal.h"
30
- #include "storage/proc.h"
31
30
#include "storage/procarray.h"
32
31
#include "utils/builtins.h"
33
32
#include "tcop/tcopprot.h"
@@ -90,7 +89,7 @@ current_query(PG_FUNCTION_ARGS)
90
89
* Functions to send signals to other backends.
91
90
*/
92
91
static bool
93
- pg_signal_check (int pid )
92
+ pg_signal_backend (int pid , int sig )
94
93
{
95
94
if (!superuser ())
96
95
ereport (ERROR ,
@@ -107,16 +106,7 @@ pg_signal_check(int pid)
107
106
(errmsg ("PID %d is not a PostgreSQL server process" , pid )));
108
107
return false;
109
108
}
110
- else
111
- return true;
112
- }
113
109
114
- /*
115
- * Functions to send signals to other backends.
116
- */
117
- static bool
118
- pg_signal_backend (int pid , int sig )
119
- {
120
110
/* If we have setsid(), signal the backend's whole process group */
121
111
#ifdef HAVE_SETSID
122
112
if (kill (- pid , sig ))
@@ -135,43 +125,7 @@ pg_signal_backend(int pid, int sig)
135
125
Datum
136
126
pg_cancel_backend (PG_FUNCTION_ARGS )
137
127
{
138
- int pid = PG_GETARG_INT32 (0 );
139
-
140
- if (pg_signal_check (pid ))
141
- PG_RETURN_BOOL (pg_signal_backend (pid , SIGINT ));
142
- else
143
- PG_RETURN_BOOL (false);
144
- }
145
-
146
- /*
147
- * To cleanly terminate a backend, we set PGPROC(pid)->terminate
148
- * then send a cancel signal. We get ProcArrayLock only when
149
- * setting PGPROC->terminate so the function might fail in
150
- * several places, but that is fine because in those cases the
151
- * backend is already gone.
152
- */
153
- Datum
154
- pg_terminate_backend (PG_FUNCTION_ARGS )
155
- {
156
- int pid = PG_GETARG_INT32 (0 );
157
- volatile PGPROC * term_proc ;
158
-
159
- /* Is this the super-user, and can we find the PGPROC entry for the pid? */
160
- if (pg_signal_check (pid ) && (term_proc = BackendPidGetProc (pid )) != NULL )
161
- {
162
- LWLockAcquire (ProcArrayLock , LW_EXCLUSIVE );
163
- /* Recheck now that we have the ProcArray lock. */
164
- if (term_proc -> pid == pid )
165
- {
166
- term_proc -> terminate = true;
167
- LWLockRelease (ProcArrayLock );
168
- PG_RETURN_BOOL (pg_signal_backend (pid , SIGINT ));
169
- }
170
- else
171
- LWLockRelease (ProcArrayLock );
172
- }
173
-
174
- PG_RETURN_BOOL (false);
128
+ PG_RETURN_BOOL (pg_signal_backend (PG_GETARG_INT32 (0 ), SIGINT ));
175
129
}
176
130
177
131
Datum
@@ -215,6 +169,17 @@ pg_rotate_logfile(PG_FUNCTION_ARGS)
215
169
PG_RETURN_BOOL (true);
216
170
}
217
171
172
+ #ifdef NOT_USED
173
+
174
+ /* Disabled in 8.0 due to reliability concerns; FIXME someday */
175
+ Datum
176
+ pg_terminate_backend (PG_FUNCTION_ARGS )
177
+ {
178
+ PG_RETURN_INT32 (pg_signal_backend (PG_GETARG_INT32 (0 ), SIGTERM ));
179
+ }
180
+ #endif
181
+
182
+
218
183
/* Function to find out which databases make use of a tablespace */
219
184
220
185
typedef struct
0 commit comments