Send Linux-ha-cvs mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."
Today's Topics:
1. Linux-HA CVS: mgmt by zhenh from
([email protected])
2. Linux-HA CVS: fencing by sunjd from
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Fri, 17 Mar 2006 02:12:07 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by zhenh from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : zhenh
Host :
Project : linux-ha
Module : mgmt
Dir : linux-ha/mgmt/client
Modified Files:
haclient.py.in
Log Message:
show the reason of failure to user
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/mgmt/client/haclient.py.in,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- haclient.py.in 10 Mar 2006 10:47:39 -0000 1.11
+++ haclient.py.in 17 Mar 2006 09:12:06 -0000 1.12
@@ -1254,6 +1254,8 @@
manager.do_cmd("del_co\nrsc_order\n"+self.cur_name)
elif self.cur_type == _("colocation") :
manager.do_cmd("del_co\nrsc_colocation\n"+self.cur_name)
+ if manager.failed_reason != "" :
+ msgbox(manager.failed_reason)
# constructor
def __init__(self) :
@@ -1342,7 +1344,7 @@
cache = {}
io_tag = None
active_nodes = []
-
+ failed_reason = ""
# cache functions
@@ -1408,15 +1410,19 @@
return True
def do_cmd(self, command) :
+ self.failed_reason = ""
ret_str = mgmt_sendmsg(command)
if ret_str == None :
debug(str(string.split(command, "\n"))+":None")
+ self.failed_reason = "return None"
return None
while len(ret_str)>=4 and ret_str[:4] == "evt:" :
ret_str = mgmt_recvmsg()
ret_list = string.split(ret_str, "\n")
if ret_list[0] != "ok" :
debug(str(string.split(command, "\n"))+":"+
str(ret_list))
+ if len(ret_list) > 1 :
+ self.failed_reason =
string.join(ret_list[1:],",")
return None
debug(str(string.split(command, "\n"))+":"+ str(ret_list))
return ret_list[1:]
@@ -1478,6 +1484,9 @@
for k,v in new_crm_config.iteritems() :
if cur_crm_config[k] != v :
self.do_cmd("up_crm_config\n"+k+"\n"+v)
+ if self.failed_reason != "" :
+ msgbox(self.failed_reason)
+
# node functions
def get_all_nodes(self) :
@@ -1511,6 +1520,8 @@
msgbox (_("the ID already exists"))
return
self.do_cmd("add_grp\n"+group["id"])
+ if self.failed_reason != "" :
+ msgbox(self.failed_reason)
def add_native(self, rsc) :
if self.do_cmd("rsc_attrs\n"+rsc["id"]) != None :
@@ -1534,6 +1545,8 @@
cmd += "\n"+param["name"]
cmd += "\n"+param["value"]
self.do_cmd(cmd)
+ if self.failed_reason != "" :
+ msgbox (self.failed_reason)
def get_all_rsc_id(self) :
if self.cache_lookup("all_rsc") != None:
@@ -1637,12 +1650,17 @@
for key in oldkeys :
if key not in newkeys :
self.do_cmd(del_cmd+"\n"+key)
+ if self.failed_reason != "" :
+ msgbox(self.failed_reason)
+
if new_attrs != [] :
for attr in new_attrs:
cmd = up_cmd
for key in keys :
cmd += "\n" + attr[key]
self.do_cmd(cmd)
+ if self.failed_reason != "" :
+ msgbox(self.failed_reason)
# clone functions
def get_clone(self, clone_id) :
@@ -1659,6 +1677,8 @@
def update_clone(self, clone) :
cmd =
"up_clone\n%s\n%s\n%s"%(clone["id"],clone["clone_max"],clone["clone_node_max"])
self.do_cmd(cmd)
+ if self.failed_reason != "" :
+ msgbox(self.failed_reason)
# master functions
def get_master(self, master_id) :
@@ -1677,6 +1697,8 @@
master["clone_max"],master["clone_node_max"],
master["master_max"],master["master_node_max"])
self.do_cmd(cmd)
+ if self.failed_reason != "" :
+ msgbox(self.failed_reason)
# constraint functions
def get_constraints(self, type) :
@@ -1730,6 +1752,8 @@
self.do_cmd("del_co\n"+type+"\n" + constraint["id"])
if type == "rsc_location" :
manager.do_cmd("del_co\nrsc_location\n"+constraint["id"])
+ if self.failed_reason != "" :
+ msgbox(self.failed_reason)
cmd =
"up_co\nrsc_location\n%s\n%s\n%s"%(constraint["id"],constraint["rsc"],constraint["score"])
for expr in constraint["exprs"] :
cmd = cmd + "\n" + expr["id"] + "\n" +
expr["attribute"] + \
@@ -1739,6 +1763,8 @@
elif type == "rsc_colocation" :
cmd = "up_co\nrsc_colocation\n%s\n%s\n%s\n%s"%
(constraint["id"],constraint["from"],constraint["to"],constraint["score"])
self.do_cmd(cmd)
+ if self.failed_reason != "" :
+ msgbox(self.failed_reason)
if __name__ == '__main__' :
if not pygtk_2_4_newer () :
------------------------------
Message: 2
Date: Fri, 17 Mar 2006 02:26:37 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: fencing by sunjd from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : sunjd
Host :
Project : linux-ha
Module : fencing
Dir : linux-ha/fencing/stonithd
Modified Files:
stonithd.c
Log Message:
- Bug 1036, memory leak
- Make code more safe on memory using
- Log tweak
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/fencing/stonithd/stonithd.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -3 -r1.85 -r1.86
--- stonithd.c 15 Mar 2006 17:13:19 -0000 1.85
+++ stonithd.c 17 Mar 2006 09:26:37 -0000 1.86
@@ -1,4 +1,4 @@
-/* $Id: stonithd.c,v 1.85 2006/03/15 17:13:19 davidlee Exp $ */
+/* $Id: stonithd.c,v 1.86 2006/03/17 09:26:37 sunjd Exp $ */
/* File: stonithd.c
* Description: STONITH daemon for node fencing
@@ -202,6 +202,8 @@
static void stonithd_hb_msg_dispatch_destroy(gpointer user_data);
static int init_hb_msg_handler(void);
static gboolean reboot_block_timeout(gpointer data);
+static void timerid_destroy_nodify(gpointer user_data);
+static void free_timer(gpointer data);
/* Local IPC communication related.
* For implementing the functions for client APIs
@@ -230,9 +232,9 @@
static int stonithRA_stop( stonithRA_ops_t * op, gpointer data );
static int stonithRA_monitor( stonithRA_ops_t * op, gpointer data );
static int stonithRA_start_post( stonithRA_ops_t * op, gpointer data );
-static int stonithop_result_to_local_client(stonith_ops_t * st_op,
- gpointer data);
-static int send_stonithop_final_result( common_op_t * op );
+static int stonithop_result_to_local_client(const stonith_ops_t * st_op
+ , gpointer data);
+static int send_stonithop_final_result( const common_op_t * op );
static int stonithop_result_to_other_node( stonith_ops_t * st_op,
gpointer data);
static int send_stonithRAop_final_result(stonithRA_ops_t * ra_op,
@@ -251,6 +253,7 @@
static stonith_rsc_t * get_local_stonithobj_can_stonith(const char * node_name,
const char * begin_rsc_id );
static int stonith_operate_locally(stonith_ops_t * st_op, stonith_rsc_t *
srsc);
+static void timeout_destroy_nodify(gpointer user_data);
static gboolean stonithop_timeout(gpointer data);
static void my_hash_table_find( GHashTable * htable, gpointer * orig_key,
gpointer * value, gpointer user_data);
@@ -491,7 +494,7 @@
/* The following line is only for CTS test with APITEST */
reboot_blocked_table = g_hash_table_new_full(g_str_hash, g_str_equal
- , g_free, g_free);
+ , g_free, free_timer);
/* To avoid the warning message when app_interval is very small. */
MY_APPHB_HB
@@ -654,8 +657,13 @@
, (gpointer *)&orignal_key, (gpointer *)&op);
if (rc == FALSE) {
- stonithd_log(LOG_NOTICE, "received child quit signal, "
- "but no this child pid in excuting list.");
+ if (SIGKILL != signo) {
+ stonithd_log(LOG_NOTICE, "received child quit signal,"
+ "but no this child pid in excuting list.");
+ } else {
+ stonithd_log2(LOG_DEBUG
+ , "A STONITH operation timeout.");
+ }
goto end;
}
@@ -899,11 +907,12 @@
if (HA_OK!=hb->llc_ops->sendnodemsg(hb, reply, from)) {
stonithd_log(LOG_ERR, "handle_msg_twhocan: "
"sendnodermsg failed.");
+ ZAPMSG(reply);
return;
}
stonithd_log(LOG_DEBUG, "handle_msg_twhocan: I can stonith "
"node %s.", target);
- stonithd_log(LOG_DEBUG,"handle_msg_twhocan: "
+ stonithd_log2(LOG_DEBUG,"handle_msg_twhocan: "
"send reply successfully.");
ZAPMSG(reply);
} else {
@@ -988,9 +997,11 @@
/* Don't handle the message about stonithing myself */
if ( strncmp(target, local_nodename, MAXCMP)
== 0) {
- stonithd_log(LOG_DEBUG, "received a T_STIT message to require "
+ stonithd_log(LOG_DEBUG, "received a T_STIT message requiring "
"to stonith myself.");
if (TEST == FALSE) {
+ stonithd_log(LOG_DEBUG, "In normal mode, donnot "
+ "stonith myself.");
return;
} else {
stonithd_log(LOG_DEBUG, "In TEST mode, continue even "
@@ -1028,13 +1039,11 @@
require_local_stonithop(stonith_ops_t * st_op, stonith_rsc_t * srsc,
const char * asker)
{
- int * child_id;
+ int child_id;
- child_id = g_new(int, 1);
- if ((*child_id = stonith_operate_locally(st_op, srsc)) <= 0) {
+ if ((child_id = stonith_operate_locally(st_op, srsc)) <= 0) {
stonithd_log(LOG_ERR, "require_local_stonithop: "
"stonith_operate_locally failed.");
- ZAPGDOBJ(child_id);
return ST_FAIL;
} else {
common_op_t * op;
@@ -1046,14 +1055,16 @@
op->rsc_id = g_strdup(srsc->rsc_id);
op->op_union.st_op = dup_stonith_ops_t(st_op);
- g_hash_table_insert(executing_queue, child_id, op);
tmp_callid = g_new(int, 1);
- *tmp_callid = *child_id;
+ *tmp_callid = child_id;
+ g_hash_table_insert(executing_queue, tmp_callid, op);
+ tmp_callid = g_new(int, 1);
+ *tmp_callid = child_id;
op->timer_id = Gmain_timeout_add_full(G_PRIORITY_HIGH_IDLE
, st_op->timeout, stonithop_timeout
- , tmp_callid, NULL);
+ , tmp_callid, timeout_destroy_nodify);
stonithd_log(LOG_DEBUG, "require_local_stonithop: inserted "
- "optype=%d, child_id=%d", st_op->optype, *child_id);
+ "optype=%d, child_id=%d", st_op->optype, child_id);
return ST_OK;
}
}
@@ -1181,7 +1192,8 @@
/* The timeout value equals 90 seconds now */
timer_id = Gmain_timeout_add_full(G_PRIORITY_HIGH_IDLE, 90*1000
- , reboot_block_timeout, g_strdup(target), NULL);
+ , reboot_block_timeout, g_strdup(target)
+ , timerid_destroy_nodify);
g_hash_table_replace(reboot_blocked_table, g_strdup(target)
, g_memdup(&timer_id, sizeof(timer_id)));
@@ -1189,11 +1201,37 @@
stonithd_log2(LOG_DEBUG, "handle_msg_trstit: end");
}
+static void
+timerid_destroy_nodify(gpointer data)
+{
+ gchar * target = (gchar *)data;
+
+ if (target != NULL) {
+ g_free(target);
+ }
+}
+
+static void
+free_timer(gpointer data)
+{
+ int * timer_id = (int *) data;
+
+ if (NULL == timer_id) {
+ stonithd_log(LOG_WARNING, "%s:%d: No invalid timer ID."
+ , __FUNCTION__, __LINE__);
+ return;
+ }
+
+ Gmain_timeout_remove(*timer_id);
+ g_free(timer_id);
+}
+
static gboolean
reboot_block_timeout(gpointer data)
{
int * timer_id;
gchar * target = (gchar *)data;
+
if (NULL !=
(timer_id=g_hash_table_lookup(reboot_blocked_table, target))) {
Gmain_timeout_remove(*timer_id);
@@ -1203,6 +1241,7 @@
stonithd_log(LOG_ERR, "An error happened When unblocking the "
" reboot to node %s" , target);
}
+
return FALSE;
}
@@ -1678,19 +1717,18 @@
ret = ST_FAIL;
goto del_st_op_and_return;
}
+
if ( (ha_msg_add(reply, F_STONITHD_TYPE, ST_APIRPL) != HA_OK )
||(ha_msg_add(reply, F_STONITHD_APIRPL, ST_RSTONITH) != HA_OK )
||(ha_msg_add(reply, F_STONITHD_APIRET, api_reply) != HA_OK )
||(ha_msg_add_int(reply, F_STONITHD_CALLID, call_id))
!= HA_OK ) {
- ZAPMSG(reply);
stonithd_log(LOG_ERR, "stonithd_node_fence: cannot add field.");
ret = ST_FAIL;
goto del_st_op_and_return;
}
if (msg2ipcchan(reply, ch) != HA_OK) {
- ZAPMSG(reply);
stonithd_log(LOG_ERR, "stonithd_node_fence: cannot send reply "
"message to IPC");
ret = ST_FAIL;
@@ -1699,10 +1737,10 @@
if (ch->ops->waitout(ch) == IPC_OK) {
stonithd_log(LOG_DEBUG, "stonithd_node_fence: end and sent "
- "back a reply.");
+ "back a synchronal reply.");
} else {
stonithd_log(LOG_DEBUG, "stonithd_node_fence: end and "
- "failed to sent back a reply.");
+ "failed to sent back a synchronal reply.");
ret = ST_FAIL;
goto del_st_op_and_return;
}
@@ -1716,6 +1754,7 @@
}
del_st_op_and_return:
+ ZAPMSG(reply);
free_stonith_ops_t(st_op);
st_op = NULL;
stonithd_log2(LOG_DEBUG, "stonithd_node_fence: end");
@@ -1755,7 +1794,7 @@
*tmp_callid = call_id;
op->timer_id = Gmain_timeout_add_full(G_PRIORITY_HIGH_IDLE
, st_op->timeout, stonithop_timeout
- , tmp_callid, NULL);
+ , tmp_callid, timeout_destroy_nodify);
stonithd_log2(LOG_DEBUG, "initiate_local_stonithop: inserted "
"optype=%d, child_id=%d", st_op->optype, call_id);
return call_id;
@@ -1800,10 +1839,14 @@
stonithd_log(LOG_DEBUG, "continue_local_stonithop: "
"removed optype=%d, key_id=%d",
op->op_union.st_op->optype, *orignal_key);
- *orignal_key = child_pid;
/* donnot need to free the old one.
* orignal_key, op is a pair of key-value.
*/
+ *orignal_key = child_pid;
+
+ if (op->rsc_id != NULL) {
+ g_free(op->rsc_id);
+ }
op->rsc_id = g_strdup(srsc->rsc_id);
g_hash_table_insert(executing_queue, orignal_key, op);
stonithd_log(LOG_DEBUG, "continue_local_stonithop: "
@@ -1851,7 +1894,7 @@
*tmp_callid = st_op->call_id;
op->timer_id = Gmain_timeout_add_full(G_PRIORITY_HIGH_IDLE
, st_op->timeout, stonithop_timeout
- , tmp_callid, NULL);
+ , tmp_callid, timeout_destroy_nodify);
stonithd_log(LOG_DEBUG, "initiate_remote_stonithop: inserted "
"optype=%d, key=%d", op->op_union.st_op->optype,
*tmp_callid);
@@ -1906,7 +1949,7 @@
}
static int
-send_stonithop_final_result( common_op_t * op)
+send_stonithop_final_result( const common_op_t * op)
{
if (op == NULL) {
stonithd_log(LOG_ERR, "send_stonithop_final_result: "
@@ -1930,7 +1973,7 @@
}
static int
-stonithop_result_to_local_client( stonith_ops_t * st_op, gpointer data)
+stonithop_result_to_local_client( const stonith_ops_t * st_op, gpointer data)
{
struct ha_msg * reply = NULL;
IPC_Channel * ch = (IPC_Channel *)data;
@@ -1969,8 +2012,9 @@
, st_op->optype, st_op->op_result);
}
- stonithd_log(LOG_DEBUG, "stonith finished: optype=%d, node_name=%s",
- st_op->optype, st_op->node_name);
+ stonithd_log2(LOG_DEBUG
+ , "stonith finished: optype=%d, node_name=%s, op_result=%d"
+ , st_op->optype, st_op->node_name, st_op->op_result);
if ((reply = ha_msg_new(0)) == NULL) {
stonithd_log(LOG_ERR, "%s:%d:ha_msg_new:out of memory."
@@ -2077,6 +2121,7 @@
if (HA_OK!=hb->llc_ops->sendnodemsg(hb, reply, node_name)) {
stonithd_log(LOG_ERR, "stonithop_result_to_other_node: "
"sendnodermsg failed.");
+ ZAPMSG(reply);
return ST_FAIL;
}
@@ -2256,6 +2301,15 @@
return NULL;
}
+static void
+timeout_destroy_nodify(gpointer user_data)
+{
+ int * call_id = (int *) user_data;
+ if (call_id != NULL) {
+ g_free(call_id);
+ }
+}
+
static gboolean
stonithop_timeout(gpointer data)
{
@@ -2269,9 +2323,20 @@
}
stonithd_log2(LOG_DEBUG, "stonithop_timeout: begin.");
- /* since g_hash_table_find donnot exist in early version of glib-2.0 */
+
+ /* since g_hash_table_find donnot exist in early version of glib-2.0,
+ * So use the equality my_hash_table_find I wrote.
+ */
my_hash_table_find(executing_queue, (gpointer *)&orig_key,
(gpointer *)&op, call_id);
+
+ /* Kill the possible child process forked for this operation */
+ if (orig_key!=NULL && *orig_key > 0 && CL_PID_EXISTS(*orig_key)) {
+ return_to_orig_privs();
+ CL_KILL(*orig_key, SIGKILL);
+ return_to_dropped_privs();
+ }
+
if ( op != NULL &&
(op->scenario == STONITH_INIT || op->scenario == STONITH_REQ)) {
if (op->op_union.st_op->optype != QUERY) {
@@ -2284,15 +2349,9 @@
/* Pay attention to not free over */
g_hash_table_remove(executing_queue, orig_key);
} else {
- stonithd_log(LOG_DEBUG, "stonithop_timeout: the stonith
operation"
- "(call_id==%d) has finished.", *call_id);
- }
-
- /* Kill the possible child process forked for this operation */
- if (orig_key!=NULL && *orig_key > 0 && CL_PID_EXISTS(*orig_key)) {
- return_to_orig_privs();
- CL_KILL(*orig_key, 9);
- return_to_dropped_privs();
+ stonithd_log(LOG_DEBUG, "stonithop_timeout: the stonith "
+ "operation (call_id==%d) has finished before timeout."
+ , *call_id);
}
return FALSE;
@@ -2586,6 +2645,7 @@
return ST_FAIL;
}
+ ZAPMSG(reply);
stonithd_log(LOG_DEBUG, "on_stonithd_list_stonith_types: end and sent "
"back a reply.");
return ST_OK;
@@ -2718,16 +2778,16 @@
return ST_OK;
}
- srsc = g_new(stonith_rsc_t, 1);
- srsc->rsc_id = ra_op->rsc_id;
- ra_op->rsc_id = NULL;
- srsc->ra_name = ra_op->ra_name;
- ra_op->ra_name = NULL;
+ /* ra_op will be free at once, so it's safe to set some of its
+ * fields as NULL.
+ */
+ srsc = g_new0(stonith_rsc_t, 1);
+ srsc->rsc_id = g_strdup(ra_op->rsc_id);
+ srsc->ra_name = g_strdup(ra_op->ra_name);
srsc->params = ra_op->params;
ra_op->params = NULL;
srsc->stonith_obj = ra_op->stonith_obj;
ra_op->stonith_obj = NULL;
- srsc->node_list = NULL;
srsc->node_list = stonith_get_hostlist(srsc->stonith_obj);
if ( debug_level >= 2 ) {
char ** this;
@@ -3361,6 +3421,11 @@
/*
* $Log: stonithd.c,v $
+ * Revision 1.86 2006/03/17 09:26:37 sunjd
+ * - Bug 1036, memory leak
+ * - Make code more safe on memory using
+ * - Log tweak
+ *
* Revision 1.85 2006/03/15 17:13:19 davidlee
* Declarations must be at head, not in middle, of a block
*
------------------------------
_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
End of Linux-ha-cvs Digest, Vol 28, Issue 35
********************************************