CVS User Account cvsuser
Wed Nov 9 23:53:21 PST 2005
Log Message:
-----------
Change the signal argument of killBackend() to type text and allow
only NULL (0 signal to test if process alive) and TERM.

Jan

Tags:
----
REL_1_1_STABLE

Modified Files:
--------------
    slony1-engine/src/backend:
        slony1_funcs.c (r1.33.2.2 -> r1.33.2.3)
        slony1_funcs.sql (r1.64.2.11 -> r1.64.2.12)

-------------- next part --------------
Index: slony1_funcs.sql
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.64.2.11
retrieving revision 1.64.2.12
diff -Lsrc/backend/slony1_funcs.sql -Lsrc/backend/slony1_funcs.sql -u -w -r1.64.2.11 -r1.64.2.12
--- src/backend/slony1_funcs.sql
+++ src/backend/slony1_funcs.sql
@@ -247,7 +247,7 @@
 			nl_backendpid from @NAMESPACE at .sl_nodelock
 			where nl_nodeid = p_failed_node for update
 	loop
-		perform @NAMESPACE at .killBackend(v_row.nl_backendpid, 15);
+		perform @NAMESPACE at .killBackend(v_row.nl_backendpid, ''TERM'');
 		delete from @NAMESPACE at .sl_nodelock
 			where nl_nodeid = v_row.nl_nodeid
 			and nl_conncnt = v_row.nl_conncnt;
@@ -261,15 +261,15 @@
   'terminates all backends that have registered to be from the given node';
 
 -- ----------------------------------------------------------------------
--- FUNCTION killBackend (pid, signo)
+-- FUNCTION killBackend (pid, signame)
 --
 --	
 -- ----------------------------------------------------------------------
-create or replace function @NAMESPACE at .killBackend (int4, int4) returns int4
+create or replace function @NAMESPACE at .killBackend (int4, text) returns int4
     as '$libdir/slony1_funcs', '_Slony_I_killBackend'
 	language C;
 
-comment on function @NAMESPACE at .killBackend(int4, int4) is
+comment on function @NAMESPACE at .killBackend(int4, text) is
   'Send a signal to a postgres process. Requires superuser rights';
 
 -- ----------------------------------------------------------------------
@@ -465,7 +465,7 @@
 			from @NAMESPACE at .sl_nodelock
 			for update
 	loop
-		if @NAMESPACE at .killBackend(v_row.nl_backendpid, 0) < 0 then
+		if @NAMESPACE at .killBackend(v_row.nl_backendpid, ''NULL'') < 0 then
 			raise notice ''Slony-I: cleanup stale sl_nodelock entry for pid=%'',
 					v_row.nl_backendpid;
 			delete from @NAMESPACE at .sl_nodelock where
Index: slony1_funcs.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.c,v
retrieving revision 1.33.2.2
retrieving revision 1.33.2.3
diff -Lsrc/backend/slony1_funcs.c -Lsrc/backend/slony1_funcs.c -u -w -r1.33.2.2 -r1.33.2.3
--- src/backend/slony1_funcs.c
+++ src/backend/slony1_funcs.c
@@ -1002,12 +1002,28 @@
 {
 	int32		pid;
 	int32		signo;
+	text	   *signame;
 
 	if (!superuser())
 		elog(ERROR, "Slony-I: insufficient privilege for killBackend");
 
 	pid		= PG_GETARG_INT32(0);
-	signo	= PG_GETARG_INT32(1);
+	signame	= PG_GETARG_TEXT_P(1);
+
+	if (VARSIZE(signame) == VARHDRSZ + 4 &&
+		memcmp(VARDATA(signame), "NULL", 0) == 0)
+	{
+		signo = 0;
+	}
+	else if (VARSIZE(signame) == VARHDRSZ + 4 &&
+		memcmp(VARDATA(signame), "TERM", 0) == 0)
+	{
+		signo = SIGTERM;
+	}
+	else
+	{
+		elog(ERROR, "Slony-I: unsupported signal");
+	}
 
 	if (kill(pid, signo) < 0)
 		PG_RETURN_INT32(-1);


More information about the Slony1-commit mailing list