Send Linux-ha-cvs mailing list submissions to
        linux-ha-cvs@lists.linux-ha.org

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: lib by andrew from 
      (linux-ha-cvs@lists.linux-ha.org)
   2. Linux-HA CVS: lib by andrew from 
      (linux-ha-cvs@lists.linux-ha.org)
   3. Linux-HA CVS: cts by lars from  (linux-ha-cvs@lists.linux-ha.org)
   4. Linux-HA CVS: crm by andrew from 
      (linux-ha-cvs@lists.linux-ha.org)


----------------------------------------------------------------------

Message: 1
Date: Tue,  4 Jul 2006 01:36:02 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/pengine


Modified Files:
        status.c 


Log Message:
strcmp() doesnt return a boolean like safe_str_eq() does :-/

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/pengine/status.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- status.c    3 Jul 2006 11:57:37 -0000       1.6
+++ status.c    4 Jul 2006 07:36:01 -0000       1.7
@@ -1,4 +1,4 @@
-/* $Id: status.c,v 1.6 2006/07/03 11:57:37 andrew Exp $ */
+/* $Id: status.c,v 1.7 2006/07/04 07:36:01 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -255,15 +255,15 @@
        for(lpc = 0; lpc < g_list_length(rsc_list); lpc++) {
                rsc = g_list_nth_data(rsc_list, lpc);
                if(rsc == NULL) {
-               } else if(rsc->id && strcmp(rsc->id, id)){
+               } else if(rsc->id && strcmp(rsc->id, id) == 0){
                        crm_debug_4("Found a match for %s", id);
                        return rsc;
                        
-               } else if(rsc->long_name && strcmp(rsc->long_name, id)) {
+               } else if(rsc->long_name && strcmp(rsc->long_name, id) == 0) {
                        crm_debug_4("Found a match for %s", id);
                        return rsc;
 
-               } else if(rsc->clone_name && strcmp(rsc->clone_name, id)) {
+               } else if(rsc->clone_name && strcmp(rsc->clone_name, id) == 0) {
                        crm_debug_4("Found a match for %s", id);
                        return rsc;
                }




------------------------------

Message: 2
Date: Tue,  4 Jul 2006 02:38:39 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/common


Modified Files:
        xml.c 


Log Message:
Drop whitespace before checking for trailing characters 

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/xml.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -3 -r1.97 -r1.98
--- xml.c       4 Jul 2006 06:24:01 -0000       1.97
+++ xml.c       4 Jul 2006 08:38:39 -0000       1.98
@@ -1,4 +1,4 @@
-/* $Id: xml.c,v 1.97 2006/07/04 06:24:01 andrew Exp $ */
+/* $Id: xml.c,v 1.98 2006/07/04 08:38:39 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -1233,6 +1233,52 @@
        return 0;
 }
 
+static gboolean
+drop_whitespace(const char *input, int *offset)
+{
+       char ch = 0;
+       int len = 0, lpc = 0;
+       gboolean more = TRUE;
+       const char *our_input = input;
+
+       if(input == NULL) {
+               return FALSE;
+       }
+       if(offset != NULL) {
+               our_input = input + (*offset);
+       }
+
+       len = strlen(our_input);
+       while(lpc < len && more) {
+               ch = our_input[lpc];
+               crm_debug_6("Processing char %c[%d]", ch, lpc);
+               switch(ch) {
+                       case 0:
+                               more = FALSE;
+                       case ' ':
+                       case '\t':
+                       case '\n':
+                       case '\r':
+                               lpc++;
+                               crm_debug_6("Skipping whitespace char %d", 
our_input[lpc]);
+                               break;
+                       default:
+                               more = FALSE;
+                               break;
+               }
+       }
+
+       crm_debug_4("Finished processing whitespace");
+       if(offset != NULL) {
+               (*offset) += lpc;
+       }
+       if(lpc > 0) {
+               crm_debug_5("Skipped %d whitespace chars", lpc);
+               return TRUE;
+       }
+       return FALSE;
+}
+
 gboolean
 drop_comments(const char *input, int *offset)
 {
@@ -1498,9 +1544,15 @@
                return NULL;
        }
        
-       if(offset == NULL && lpc+1 < (ssize_t)strlen(input)) {
-               crm_err("Ignoring trailing characters in XML input: Parsed %d 
characters of a possible %d",
-                       lpc, (int)strlen(input));
+       if(offset == NULL) {
+               lpc++;
+               drop_comments(our_input, &lpc);
+               drop_whitespace(our_input, &lpc);
+               if(lpc < (ssize_t)strlen(input)) {
+                       crm_err("Ignoring trailing characters in XML input.");
+                       crm_err("Parsed %d characters of a possible %d.  
Trailing text was: ...\'%20s\'",
+                               lpc, (int)strlen(input), input+lpc);
+               }
        }
        
        crm_debug_4("Finished processing %s tag", tag_name);
@@ -1529,8 +1581,6 @@
                }
                
                );
-/*     crm_log_maybe(log_level, " === "); */
-
        is_first = TRUE;
        xml_child_iter(
                added, child, 




------------------------------

Message: 3
Date: Tue,  4 Jul 2006 07:36:09 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: cts by lars from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : lars
Host    : 
Project : linux-ha
Module  : cts

Dir     : linux-ha/cts


Modified Files:
        CTS.py.in 


Log Message:
NodeStatus should use the RemoteExec class too, otherwise BSC might hang
if unable to ssh in w/o confirmation to the localhost.

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/cts/CTS.py.in,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -3 -r1.62 -r1.63
--- CTS.py.in   30 Jun 2006 02:15:17 -0000      1.62
+++ CTS.py.in   4 Jul 2006 13:36:08 -0000       1.63
@@ -358,12 +358,14 @@
 class NodeStatus:
     def __init__(self, Env):
         self.Env = Env
+        self.rsh = RemoteExec()
+
     def IsNodeBooted(self, node):
         '''Return TRUE if the given node is booted (responds to pings'''
         return os.system("@PING@ -nq -c1 @PING_TIMEOUT_OPT@ %s >/dev/null 
2>&1" % node) == 0
 
     def IsSshdUp(self, node):
-         return os.system("@SSH@ %s echo >/dev/null 2>&1" % node) == 0
+         return self.rsh(node, "true") == 0;
 
     def WaitForNodeToComeUp(self, node, Timeout=300):
         '''Return TRUE when given node comes up, or None/FALSE if timeout'''




------------------------------

Message: 4
Date: Tue,  4 Jul 2006 08:07:43 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: crm by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : crm

Dir     : linux-ha/crm/cib


Modified Files:
        callbacks.c cibio.h io.c messages.c 


Log Message:
Split some monolithic functions into smaller pieces
Abstract out common actions from the CIB worker functions
Some extra helper functions for dealing with memory statistics
Selectivly disable memory statistic tracking in the CIB so that we can 
  check if it leaks (regardless of how the contents of the CIB changes).
Some (disabled) code for fingering the messaging code as the source of 
  CIB memory leaks. 

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/cib/callbacks.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -3 -r1.126 -r1.127
--- callbacks.c 3 Jul 2006 15:15:30 -0000       1.126
+++ callbacks.c 4 Jul 2006 14:07:42 -0000       1.127
@@ -1,4 +1,4 @@
-/* $Id: callbacks.c,v 1.126 2006/07/03 15:15:30 andrew Exp $ */
+/* $Id: callbacks.c,v 1.127 2006/07/04 14:07:42 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -53,6 +53,9 @@
 extern gboolean cib_shutdown_flag;
 extern gboolean stand_alone;
 
+extern enum cib_errors cib_update_counter(
+       crm_data_t *xml_obj, const char *field, gboolean reset);
+
 extern void GHFunc_count_peers(
        gpointer key, gpointer value, gpointer user_data);
 extern enum cib_errors revision_check(
@@ -446,26 +449,34 @@
 gboolean
 cib_rw_callback(IPC_Channel *channel, gpointer user_data)
 {
-       return cib_common_callback(channel, user_data, FALSE, TRUE);
+       gboolean result = FALSE;
+       result = cib_common_callback(channel, user_data, FALSE, TRUE);
+       return result;
 }
 
 
 gboolean
 cib_ro_synchronous_callback(IPC_Channel *channel, gpointer user_data)
 {
-       return cib_common_callback(channel, user_data, TRUE, FALSE);
+       gboolean result = FALSE;
+       result = cib_common_callback(channel, user_data, TRUE, FALSE);
+       return result;
 }
 
 gboolean
 cib_rw_synchronous_callback(IPC_Channel *channel, gpointer user_data)
 {
-       return cib_common_callback(channel, user_data, TRUE, TRUE);
+       gboolean result = FALSE;
+       result = cib_common_callback(channel, user_data, TRUE, TRUE);
+       return result;
 }
 
 gboolean
 cib_ro_callback(IPC_Channel *channel, gpointer user_data)
 {
-       return cib_common_callback(channel, user_data, FALSE, FALSE);
+       gboolean result = FALSE;
+       result = cib_common_callback(channel, user_data, FALSE, FALSE);
+       return result;
 }
 
 gboolean
@@ -609,6 +620,8 @@
 
        longclock_t call_stop = 0;
        longclock_t call_start = 0;
+       cl_mem_stats_t saved_stats;
+       crm_save_mem_stats(__PRETTY_FUNCTION__, &saved_stats);
 
        call_start = time_longclock();
        cib_client->num_calls++;
@@ -624,21 +637,16 @@
                            op, cib_client->name, cib_client->channel_name);
        }
        
-       crm_log_message_adv(LOG_MSG, "Client[inbound]", op_request);
-       ha_msg_add(op_request, F_CIB_CLIENTID, cib_client->id);
-       ha_msg_add(op_request, F_CIB_CLIENTNAME, cib_client->name);
-
        if(rc == cib_ok) {
                cib_process_request(
                        op_request, force_synchronous, privileged, FALSE,
                        cib_client);
        }
                
-       crm_debug_3("Cleaning up request");
-       crm_msg_del(op_request);
-
        call_stop = time_longclock();
        cib_call_time += (call_stop - call_start);
+
+       crm_diff_mem_stats(LOG_WARNING, __PRETTY_FUNCTION__, &saved_stats);
 }
 
 gboolean
@@ -680,10 +688,18 @@
 
                lpc++;
                crm_assert_failed = FALSE;
+
+               crm_log_message_adv(LOG_MSG, "Client[inbound]", op_request);
+               ha_msg_add(op_request, F_CIB_CLIENTID, cib_client->id);
+               ha_msg_add(op_request, F_CIB_CLIENTNAME, cib_client->name);
+               
                cib_common_callback_worker(
                        op_request, cib_client, force_synchronous, privileged);
-               
+
+               crm_debug_3("Cleaning up request");
+               crm_msg_del(op_request);
                op_request = NULL;              
+
                if(channel->ch_status == IPC_CONNECT) {
                        break;
                }
@@ -700,6 +716,291 @@
        return keep_channel;
 }
 
+static void
+do_local_notify(HA_Message *notify_src, const char *client_id, gboolean 
sync_reply, gboolean from_peer) 
+{
+       /* send callback to originating child */
+       cib_client_t *client_obj = NULL;
+       HA_Message *client_reply = NULL;
+       enum cib_errors local_rc = cib_ok;
+       cl_mem_stats_t saved_stats;
+       crm_save_mem_stats(__PRETTY_FUNCTION__, &saved_stats);
+
+       crm_debug_2("Performing notification");
+       
+       client_reply = cib_msg_copy(notify_src, TRUE);
+       
+       if(client_id != NULL) {
+               client_obj = g_hash_table_lookup(
+                       client_list, client_id);
+       } else {
+               crm_debug("No client to sent the response to."
+                         "  F_CIB_CLIENTID not set.");
+       }
+       
+       crm_debug_3("Sending callback to request originator");
+       if(client_obj == NULL) {
+               local_rc = cib_reply_failed;
+               ha_msg_del(client_reply);
+               
+       } else {
+               const char *client_id = client_obj->callback_id;
+               crm_debug_2("Sending %ssync response to %s %s",
+                           sync_reply?"":"an a-",
+                           client_obj->name,
+                           from_peer?"(originator of delegated request)":"");
+               
+               if(sync_reply) {
+                       client_id = client_obj->id;
+               }
+               local_rc = send_via_callback_channel(client_reply, client_id);
+               
+               client_reply = NULL;
+       } 
+       
+       if(local_rc != cib_ok) {
+               crm_warn("%sSync reply to %s failed: %s",
+                        sync_reply?"":"A-",
+                        client_obj?client_obj->name:"<unknown>", 
cib_error2string(local_rc));
+       }
+       crm_diff_mem_stats(LOG_ERR, __PRETTY_FUNCTION__, &saved_stats);
+}
+
+static void
+parse_local_options(
+       cib_client_t *cib_client, int call_type, int call_options, const char 
*host, const char *op, 
+       gboolean *local_notify, gboolean *needs_reply, gboolean *process, 
gboolean *needs_forward) 
+{
+       if(cib_server_ops[call_type].modifies_cib
+          && !(call_options & cib_inhibit_bcast)) {
+               /* we need to send an update anyway */
+               *needs_reply = TRUE;
+       } else {
+               *needs_reply = FALSE;
+       }
+       
+       if(host == NULL && (call_options & cib_scope_local)) {
+               crm_debug("Processing locally scoped %s op from %s",
+                         op, cib_client->name);
+               *local_notify = TRUE;
+               
+       } else if(host == NULL && cib_is_master) {
+               crm_debug("Processing master %s op locally from %s",
+                         op, cib_client->name);
+               *local_notify = TRUE;
+               
+       } else if(safe_str_eq(host, cib_our_uname)) {
+               crm_debug("Processing locally addressed %s op from %s",
+                         op, cib_client->name);
+               *local_notify = TRUE;
+       } else {
+               crm_debug("%s op from %s needs to be forwarded to %s",
+                         op, cib_client->name,
+                         host?host:"the master instance");
+               *needs_forward = TRUE;
+               *process = FALSE;
+       }               
+}
+
+static gboolean
+parse_peer_options(
+       cib_client_t *cib_client, int call_type, HA_Message *request, 
+       gboolean *local_notify, gboolean *needs_reply, gboolean *process, 
gboolean *needs_forward) 
+{
+       const char *op         = cl_get_string(request, F_CIB_OPERATION);
+       const char *originator = cl_get_string(request, F_ORIG);
+       const char *host       = cl_get_string(request, F_CIB_HOST);
+       const char *reply_to   = cl_get_string(request, F_CIB_ISREPLY);
+       const char *update     = cl_get_string(request, F_CIB_GLOBAL_UPDATE);
+       const char *delegated  = cl_get_string(request, F_CIB_DELEGATED);
+
+       if(safe_str_eq(op, "cib_shutdown_req")) {
+               if(reply_to != NULL) {
+                       crm_debug("Processing %s from %s", op, host);
+                       *needs_reply = FALSE;
+                       
+               } else {
+                       crm_debug("Processing %s reply from %s", op, host);
+               }
+               return TRUE;
+               
+       } else if(crm_is_true(update) && safe_str_eq(reply_to, cib_our_uname)) {
+               crm_debug("Processing global/peer update from %s"
+                         " that originated from us", originator);
+               *needs_reply = FALSE;
+               if(cl_get_string(request, F_CIB_CLIENTID) != NULL) {
+                       *local_notify = TRUE;
+               }
+               return TRUE;
+               
+       } else if(crm_is_true(update)) {
+               crm_debug("Processing global/peer update from %s", originator);
+               *needs_reply = FALSE;
+               return TRUE;
+
+       } else if(host != NULL && safe_str_eq(host, cib_our_uname)) {
+               crm_debug("Processing request sent to us from %s", originator);
+               return TRUE;
+
+       } else if(delegated != NULL && cib_is_master == TRUE) {
+               crm_debug("Processing request sent to master instance from %s",
+                       originator);
+               return TRUE;
+
+       } else if(reply_to != NULL && safe_str_eq(reply_to, cib_our_uname)) {
+               crm_debug("Forward reply sent from %s to local clients",
+                         originator);
+               *process = FALSE;
+               *needs_reply = FALSE;
+               *local_notify = TRUE;
+               return TRUE;
+
+       } else if(delegated != NULL) {
+               crm_debug("Ignoring msg for master instance");
+
+       } else if(host != NULL) {
+               /* this is for a specific instance and we're not it */
+               crm_debug("Ignoring msg for instance on %s", crm_str(host));
+               
+       } else if(reply_to == NULL && cib_is_master == FALSE) {
+               /* this is for the master instance and we're not it */
+               crm_debug("Ignoring reply to %s", crm_str(reply_to));
+               
+       } else {
+               crm_err("Nothing for us to do?");
+               crm_log_message_adv(LOG_ERR, "Peer[inbound]", request);
+       }
+
+       return FALSE;
+}
+
+               
+static void
+forward_request(HA_Message *request, cib_client_t *cib_client,
+               int call_options, const char *host, const char *op)
+{
+       HA_Message *forward_msg = NULL;
+       cl_mem_stats_t saved_stats;
+       crm_save_mem_stats(__PRETTY_FUNCTION__, &saved_stats);
+
+       forward_msg = cib_msg_copy(request, TRUE);
+       ha_msg_add(forward_msg, F_CIB_DELEGATED, cib_our_uname);
+       
+       if(host != NULL) {
+               crm_debug_2("Forwarding %s op to %s", op, host);
+               send_ha_message(hb_conn, forward_msg, host, FALSE);
+               
+       } else {
+               crm_debug_2("Forwarding %s op to master instance", op);
+               send_ha_message(hb_conn, forward_msg, NULL, FALSE);
+       }
+       
+       if(call_options & cib_discard_reply) {
+               crm_debug_2("Client not interested in reply");
+               
+       } else if(call_options & cib_sync_call) {
+               /* keep track of the request so we can time it
+                * out if required
+                */
+               crm_err("Registering delegated call from %s",
+                       cib_client->id);
+               cib_client->delegated_calls = g_list_append(
+                       cib_client->delegated_calls, forward_msg);
+               forward_msg = NULL;
+               
+       } 
+       crm_msg_del(forward_msg);
+       crm_diff_mem_stats(LOG_ERR, __PRETTY_FUNCTION__, &saved_stats);
+}
+
+static void
+send_peer_reply(HA_Message *msg, crm_data_t *result_diff, const char 
*originator, gboolean broadcast)
+{
+       cl_mem_stats_t saved_stats;
+       HA_Message *reply_copy = NULL;
+
+       CRM_ASSERT(msg != NULL);
+
+       crm_save_mem_stats(__PRETTY_FUNCTION__, &saved_stats);
+       reply_copy = cib_msg_copy(msg, FALSE);
+       
+       if(broadcast) {
+               /* this (successful) call modified the CIB _and_ the
+                * change needs to be broadcast...
+                *   send via HA to other nodes
+                */
+               int diff_add_updates = 0;
+               int diff_add_epoch   = 0;
+               int diff_add_admin_epoch = 0;
+               
+               int diff_del_updates = 0;
+               int diff_del_epoch   = 0;
+               int diff_del_admin_epoch = 0;
+               
+               cib_diff_version_details(
+                       result_diff,
+                       &diff_add_admin_epoch, &diff_add_epoch, 
&diff_add_updates, 
+                       &diff_del_admin_epoch, &diff_del_epoch, 
&diff_del_updates);
+
+               crm_debug("Sending update diff %d.%d.%d -> %d.%d.%d",
+                           
diff_del_admin_epoch,diff_del_epoch,diff_del_updates,
+                           
diff_add_admin_epoch,diff_add_epoch,diff_add_updates);
+
+               ha_msg_add(reply_copy, F_CIB_ISREPLY, originator);
+               ha_msg_add(reply_copy, F_CIB_GLOBAL_UPDATE, XML_BOOLEAN_TRUE);
+               ha_msg_mod(reply_copy, F_CIB_OPERATION, CIB_OP_APPLY_DIFF);
+
+               add_message_xml(reply_copy, F_CIB_UPDATE_DIFF, result_diff);
+               crm_log_message(LOG_DEBUG_3, reply_copy);
+#if 1
+               send_ha_message(hb_conn, reply_copy, NULL, TRUE);
+#else          
+               /* code to verify the messaging layer leaks */ 
+               CRM_ASSERT(hb_conn->llc_ops->sendclustermsg(hb_conn, 
reply_copy) == HA_OK);
+               {
+                       IPC_Channel *ipc = NULL;
+                       IPC_Queue *send_q = NULL;
+                       ipc = hb_conn->llc_ops->ipcchan(hb_conn);
+                       if(ipc != NULL) {
+                               ipc->ops->waitout(ipc);
+                               send_q = ipc->send_queue;
+                       }
+                       if(send_q != NULL) {
+                               CRM_CHECK(send_q->current_qlen == 0 ,
+                                         crm_err("Send Queue len: %d", 
(int)send_q->current_qlen));
+                       }
+               }
+#endif
+               
+       } else if(originator != NULL) {
+               /* send reply via HA to originating node */
+               crm_debug_2("Sending request result to originator only");
+               ha_msg_add(reply_copy, F_CIB_ISREPLY, originator);
+#if 1
+               send_ha_message(hb_conn, reply_copy, originator, FALSE);
+#else          
+               /* code to verify the messaging layer leaks */ 
+               CRM_ASSERT(hb_conn->llc_ops->send_ordered_nodemsg(hb_conn, 
reply_copy) == HA_OK);
+               {
+                       IPC_Channel *ipc = NULL;
+                       IPC_Queue *send_q = NULL;
+                       ipc = hb_conn->llc_ops->ipcchan(hb_conn);
+                       if(ipc != NULL) {
+                               ipc->ops->waitout(ipc);
+                               send_q = ipc->send_queue;
+                       }
+                       if(send_q != NULL) {
+                               CRM_CHECK(send_q->current_qlen == 0 ,
+                                         crm_err("Send Queue len: %d", 
(int)send_q->current_qlen));
+                       }
+               }
+#endif
+       }
+       
+       crm_msg_del(reply_copy);
+       crm_diff_mem_stats(LOG_ERR, __PRETTY_FUNCTION__, &saved_stats);
+}
+       
 void
 cib_process_request(
        HA_Message *request, gboolean force_synchronous, gboolean privileged,
@@ -720,10 +1021,7 @@
        const char *op         = cl_get_string(request, F_CIB_OPERATION);
        const char *originator = cl_get_string(request, F_ORIG);
        const char *host       = cl_get_string(request, F_CIB_HOST);
-       const char *reply_to   = cl_get_string(request, F_CIB_ISREPLY);
        const char *update     = cl_get_string(request, F_CIB_GLOBAL_UPDATE);
-       const char *delegated  = cl_get_string(request, F_CIB_DELEGATED);
-       const char *client_id  = NULL;
 
        crm_debug_4("%s Processing msg %s",
                  cib_our_uname, cl_get_string(request, F_SEQ));
@@ -756,96 +1054,17 @@
                cib_num_updates++;
        }
        
-       
        if(rc != cib_ok) {
                /* TODO: construct error reply */
                crm_err("Pre-processing of command failed: %s",
                        cib_error2string(rc));
                
        } else if(from_peer == FALSE) {
-
-               if(cib_server_ops[call_type].modifies_cib
-                  && !(call_options & cib_inhibit_bcast)) {
-                       /* we need to send an update anyway */
-                       needs_reply = TRUE;
-               } else {
-                       needs_reply = FALSE;
-               }
-               
-               if(host == NULL && (call_options & cib_scope_local)) {
-                       crm_debug("Processing locally scoped %s op from %s",
-                                 op, cib_client->name);
-                       local_notify = TRUE;
-
-               } else if(host == NULL && cib_is_master) {
-                       crm_debug("Processing master %s op locally from %s",
-                                 op, cib_client->name);
-                       local_notify = TRUE;
-
-               } else if(safe_str_eq(host, cib_our_uname)) {
-                       crm_debug("Processing locally addressed %s op from %s",
-                                 op, cib_client->name);
-                       local_notify = TRUE;
-               } else {
-                       crm_debug("%s op from %s needs to be forwarded to %s",
-                                 op, cib_client->name,
-                                 host?host:"the master instance");
-                       needs_forward = TRUE;
-                       process = FALSE;
-               }
-               
-       } else if(safe_str_eq(op, "cib_shutdown_req")) {
-               if(reply_to != NULL) {
-                       crm_debug("Processing %s from %s", op, host);
-                       needs_reply = FALSE;
-                       
-               } else {
-                       crm_debug("Processing %s reply from %s", op, host);
-               }
-               
-       } else if(crm_is_true(update) && safe_str_eq(reply_to, cib_our_uname)) {
-               crm_debug("Processing global/peer update from %s"
-                         " that originated from us", originator);
-               needs_reply = FALSE;
-               if(cl_get_string(request, F_CIB_CLIENTID) != NULL) {
-                       local_notify = TRUE;
-               }
+               parse_local_options(cib_client, call_type, call_options, host, 
op,
+                                   &local_notify, &needs_reply, &process, 
&needs_forward);
                
-       } else if(crm_is_true(update)) {
-               crm_debug("Processing global/peer update from %s", originator);
-               needs_reply = FALSE;
-
-       } else if(host != NULL && safe_str_eq(host, cib_our_uname)) {
-               crm_debug("Processing request sent to us from %s", originator);
-
-       } else if(delegated != NULL && cib_is_master == TRUE) {
-               crm_debug("Processing request sent to master instance from %s",
-                       originator);
-
-       } else if(reply_to != NULL && safe_str_eq(reply_to, cib_our_uname)) {
-               crm_debug("Forward reply sent from %s to local clients",
-                         originator);
-               process = FALSE;
-               needs_reply = FALSE;
-               local_notify = TRUE;
-
-       } else if(delegated != NULL) {
-               crm_debug("Ignoring msg for master instance");
-               return;
-
-       } else if(host != NULL) {
-               /* this is for a specific instance and we're not it */
-               crm_debug("Ignoring msg for instance on %s", crm_str(host));
-               return;
-               
-       } else if(reply_to == NULL && cib_is_master == FALSE) {
-               /* this is for the master instance and we're not it */
-               crm_debug("Ignoring %s reply to %s", op, crm_str(reply_to));
-               return;
-               
-       } else {
-               crm_err("Nothing for us to do?");
-               crm_log_message_adv(LOG_ERR, "Peer[inbound]", request);
+       } else if(parse_peer_options(cib_client, call_type, request,
+                                    &local_notify, &needs_reply, &process, 
&needs_forward) == FALSE) {
                return;
        }
        crm_debug_3("Finished determining processing actions");
@@ -856,33 +1075,7 @@
        }
        
        if(needs_forward && stand_alone == FALSE) {
-               HA_Message *forward_msg = cib_msg_copy(request, TRUE);
-               ha_msg_add(forward_msg, F_CIB_DELEGATED, cib_our_uname);
-               
-               if(host != NULL) {
-                       crm_debug_2("Forwarding %s op to %s", op, host);
-                       send_ha_message(hb_conn, forward_msg, host, FALSE);
-                       
-               } else {
-                       crm_debug_2("Forwarding %s op to master instance", op);
-                       send_ha_message(hb_conn, forward_msg, NULL, FALSE);
-               }
-               
-               if(call_options & cib_discard_reply) {
-                       crm_debug_2("Client not interested in reply");
-                       crm_msg_del(forward_msg);
-                       
-               } else if(call_options & cib_sync_call) {
-                       /* keep track of the request so we can time it
-                        * out if required
-                        */
-                       crm_debug_2("Registering delegated call from %s",
-                                   cib_client->id);
-                       cib_client->delegated_calls = g_list_append(
-                               cib_client->delegated_calls, forward_msg);
-               } else {
-                       crm_msg_del(forward_msg);
-               }
+               forward_request(request, cib_client, call_options, host, op);
                return;
        }
 
@@ -923,125 +1116,52 @@
        crm_debug_3("processing response cases");
 
        if(local_notify) {
-               /* send callback to originating child */
-               cib_client_t *client_obj = NULL;
-               HA_Message *client_reply = NULL;
-               enum cib_errors local_rc = cib_ok;
-               crm_debug_2("Performing notification");
-
+               const char *client_id = cl_get_string(request, F_CIB_CLIENTID);
                if(process == FALSE) {
-                       client_reply = cib_msg_copy(request, TRUE);
+                       do_local_notify(request, client_id, call_options & 
cib_sync_call, from_peer);
                } else {
-                       /* can we set this to FALSE? */
-                       client_reply = cib_msg_copy(op_reply, TRUE);
-               }
-               
-               client_id = cl_get_string(request, F_CIB_CLIENTID);
-               if(client_id != NULL) {
-                       client_obj = g_hash_table_lookup(
-                               client_list, client_id);
-               } else {
-                       crm_debug("No client to sent the response to."
-                                 "  F_CIB_CLIENTID not set.");
-               }
-               
-               crm_debug_3("Sending callback to request originator");
-               if(client_obj == NULL) {
-                       local_rc = cib_reply_failed;
-                       
-               } else {
-                       const char *client_id = client_obj->callback_id;
-                       crm_debug_2("Sending %ssync response to %s %s",
-                                 (call_options & cib_sync_call)?"":"an a-",
-                                 client_obj->name,
-                                 from_peer?"(originator of delegated 
request)":"");
-
-                       if(call_options & cib_sync_call) {
-                               client_id = client_obj->id;
-                       }
-                       local_rc = send_via_callback_channel(
-                               client_reply, client_id);
-
-                       client_reply = NULL;
-               } 
-
-               if(local_rc != cib_ok) {
-                       crm_warn("%sSync reply to %s failed: %s",
-                                (call_options & cib_sync_call)?"":"A-",
-                                client_obj?client_obj->name:"<unknown>", 
cib_error2string(local_rc));
-                       crm_log_message(LOG_DEBUG, op_reply);
+                       do_local_notify(op_reply, client_id, call_options & 
cib_sync_call, from_peer);
                }
        }
 
+       /* from now on we are the server */ 
        if(needs_reply == FALSE || stand_alone) {
                /* nothing more to do...
                 * this was a non-originating slave update
                 */
                crm_debug_2("Completed slave update");
-               crm_msg_del(op_reply);
-               free_xml(result_diff);
-               return;
-       }
-       
-       crm_debug_4("add the originator to message");
 
-       CRM_DEV_ASSERT(op_reply != NULL);
-       CRM_DEV_ASSERT(cib_server_ops[call_type].modifies_cib == FALSE
-                      || result_diff != NULL || rc != cib_ok);
-       
-       /* from now on we are the server */ 
-       if(rc == cib_ok
+       } else if(rc == cib_ok
           && result_diff != NULL
           && !(call_options & cib_inhibit_bcast)) {
-               /* this (successful) call modified the CIB _and_ the
-                * change needs to be broadcast...
-                *   send via HA to other nodes
-                */
-               HA_Message *op_bcast = cib_msg_copy(request, FALSE);
-               int diff_add_updates = 0;
-               int diff_add_epoch  = 0;
-               int diff_add_admin_epoch = 0;
-               
-               int diff_del_updates = 0;
-               int diff_del_epoch  = 0;
-               int diff_del_admin_epoch = 0;
-               
-               cib_diff_version_details(
-                       result_diff,
-                       &diff_add_admin_epoch, &diff_add_epoch, 
&diff_add_updates, 
-                       &diff_del_admin_epoch, &diff_del_epoch, 
&diff_del_updates);
-
-               crm_debug("Sending update diff %d.%d.%d -> %d.%d.%d",
-                           
diff_del_admin_epoch,diff_del_epoch,diff_del_updates,
-                           
diff_add_admin_epoch,diff_add_epoch,diff_add_updates);
-
-               ha_msg_add(op_bcast, F_CIB_ISREPLY, originator);
-               ha_msg_add(op_bcast, F_CIB_GLOBAL_UPDATE, XML_BOOLEAN_TRUE);
-               ha_msg_mod(op_bcast, F_CIB_OPERATION, CIB_OP_APPLY_DIFF);
-
-               add_message_xml(op_bcast, F_CIB_UPDATE_DIFF, result_diff);
-               crm_log_message(LOG_DEBUG_3, op_bcast);
-               send_ha_message(hb_conn, op_bcast, NULL, TRUE);
-               crm_msg_del(op_bcast);
+               CRM_DEV_ASSERT(cib_server_ops[call_type].modifies_cib == FALSE
+                              || result_diff != NULL || rc != cib_ok);
+               send_peer_reply(request, result_diff, originator, TRUE);
                
        } else if((call_options & cib_discard_reply) == 0) {
-               crm_debug_2("Sending replies");
-               if(from_peer && originator != NULL) {
-                       /* send reply via HA to originating node */
-                       crm_debug_2("Sending request result to originator 
only");
-                       ha_msg_add(op_reply, F_CIB_ISREPLY, originator);
-                       send_ha_message(hb_conn, op_reply, originator, FALSE);
-               }
+               gboolean should_send = TRUE;
+               CRM_DEV_ASSERT(cib_server_ops[call_type].modifies_cib == FALSE
+                              || result_diff != NULL || rc != cib_ok);
+               
                if(call_options & cib_inhibit_bcast ) {
+                       should_send = FALSE;
                        crm_debug("Request not broadcast: inhibited");
                }
                if(cib_server_ops[call_type].modifies_cib == FALSE) {
+                       should_send = FALSE;
                        crm_debug_2("Request not broadcast: R/O call");
                }
                if(rc != cib_ok) {
+                       should_send = FALSE;
                        crm_warn("Request not broadcast: call failed: %s",
                                 cib_error2string(rc));
                }
+               if(from_peer == FALSE) {
+                       should_send = FALSE;
+               }
+               if(should_send) {
+                       send_peer_reply(op_reply, result_diff, originator, 
FALSE);
+               }
        }
        
        crm_msg_del(op_reply);
@@ -1153,6 +1273,10 @@
                }
 
                if(rc == cib_ok) {
+                       START_stat_free_op();
+                       result_cib = copy_xml(current_cib);
+                       END_stat_free_op();
+
                        rc = cib_server_ops[call_type].fn(
                                op, call_options, section, input,
                                current_cib, &result_cib, &output);
@@ -1163,6 +1287,15 @@
                        CRM_DEV_ASSERT(current_cib != result_cib);
 
                        update_counters(__FILE__, __FUNCTION__, result_cib);
+
+                       if(section == NULL && cib_server_ops[call_type].fn == 
cib_process_replace) {
+                               /* skip */
+                       } else if(cib_server_ops[call_type].fn == 
cib_process_change
+                                 && (call_options & cib_inhibit_bcast)) {
+                               /* skip */
+                       } else {
+                               cib_update_counter(result_cib, 
XML_ATTR_NUMUPDATES, FALSE);
+                       }
                        
                        if(do_id_check(result_cib, NULL, TRUE, FALSE)) {
                                rc = cib_id_check;
@@ -1177,8 +1310,10 @@
                }
 
                if(rc != cib_ok) {
+                       START_stat_free_op();
                        free_xml(result_cib);
-
+                       END_stat_free_op();
+                       
                } else if(activateCibXml(result_cib, CIB_FILENAME) != 0){
                        crm_warn("Activation failed");
                        rc = cib_ACTIVATION;
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/cib/cibio.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- cibio.h     8 Mar 2006 22:24:29 -0000       1.16
+++ cibio.h     4 Jul 2006 14:07:42 -0000       1.17
@@ -1,4 +1,4 @@
-/* $Id: cibio.h,v 1.16 2006/03/08 22:24:29 andrew Exp $ */
+/* $Id: cibio.h,v 1.17 2006/07/04 14:07:42 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -59,5 +59,8 @@
        const char *file, const char *fn, crm_data_t *xml_obj);
 
 /* extern crm_data_t *server_get_cib_copy(void); */
+extern volatile cl_mem_stats_t *active_stats;
+#define START_stat_free_op() active_stats = cl_malloc_getstats(); 
cl_malloc_setstats(NULL); 
+#define END_stat_free_op() cl_malloc_setstats(active_stats);
 
 #endif
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/cib/io.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -3 -r1.71 -r1.72
--- io.c        22 Jun 2006 15:11:56 -0000      1.71
+++ io.c        4 Jul 2006 14:07:42 -0000       1.72
@@ -1,4 +1,4 @@
-/* $Id: io.c,v 1.71 2006/06/22 15:11:56 andrew Exp $ */
+/* $Id: io.c,v 1.72 2006/07/04 14:07:42 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -557,6 +557,7 @@
                CRM_DEV_ASSERT(the_cib == NULL);
        }
 
+       START_stat_free_op();
        if(the_cib != new_cib) {
                free_xml(new_cib);
                CRM_DEV_ASSERT(error_code != cib_ok);
@@ -565,6 +566,7 @@
        if(the_cib != saved_cib) {
                free_xml(saved_cib);
        }
+       END_stat_free_op();
        
        return error_code;
     
@@ -702,9 +704,11 @@
 {
        gboolean did_update = FALSE;
 
+       START_stat_free_op();
        did_update = did_update || update_quorum(xml_obj);
        did_update = did_update || set_transition(xml_obj);
        did_update = did_update || set_connected_peers(xml_obj);
+       END_stat_free_op();
        
        if(did_update) {
                do_crm_log(LOG_DEBUG, file, fn, "Counters updated");
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/cib/messages.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -3 -r1.82 -r1.83
--- messages.c  3 Jul 2006 15:27:06 -0000       1.82
+++ messages.c  4 Jul 2006 14:07:42 -0000       1.83
@@ -1,4 +1,4 @@
-/* $Id: messages.c,v 1.82 2006/07/03 15:27:06 andrew Exp $ */
+/* $Id: messages.c,v 1.83 2006/07/04 14:07:42 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -48,6 +48,7 @@
 #include <crm/dmalloc_wrapper.h>
 
 #define MAX_DIFF_RETRY 5
+volatile cl_mem_stats_t *active_stats = NULL;
 
 extern const char *cib_our_uname;
 extern gboolean syncd_once;
@@ -232,13 +233,12 @@
 
        crm_debug_2("Processing \"%s\" event", op);
        *answer = NULL;
+       free_xml(*result_cib);
        *result_cib = createEmptyCib();
 
-       copy_in_properties(*result_cib, existing_cib);
-       
+       copy_in_properties(*result_cib, existing_cib);  
        cib_update_counter(*result_cib, XML_ATTR_GENERATION, FALSE);
-       cib_update_counter(*result_cib, XML_ATTR_NUMUPDATES, TRUE);
-
+       
        local_diff = diff_cib_object(existing_cib, *result_cib, FALSE);
        cib_replace_notify(*result_cib, result, local_diff);
        free_xml(local_diff);
@@ -257,10 +257,7 @@
                  op, crm_str(crm_element_value(the_cib, XML_ATTR_GENERATION)));
        
        *answer = NULL;
-       *result_cib = copy_xml(the_cib);
-
        cib_update_counter(*result_cib, XML_ATTR_GENERATION, FALSE);
-       cib_update_counter(*result_cib, XML_ATTR_NUMUPDATES, FALSE);
        
        return result;
 }
@@ -288,6 +285,8 @@
        char *old_value = NULL;
        int  int_value  = -1;
 
+       START_stat_free_op();
+       
        if(reset == FALSE && crm_element_value(xml_obj, field) != NULL) {
                old_value = crm_element_value_copy(xml_obj, field);
        }
@@ -303,8 +302,9 @@
                  field, int_value, crm_str(old_value), crm_str(new_value));
        crm_xml_add(xml_obj, field, new_value);
        crm_free(new_value);
-
        crm_free(old_value);
+
+       END_stat_free_op();     
        return cib_ok;
 }
 
@@ -423,20 +423,22 @@
                reason = "current \""XML_ATTR_NUMUPDATES"\" is greater than 
required";
        }
 
-       if(apply_diff
-          && apply_xml_diff(existing_cib, input, result_cib) == FALSE) {
-               log_level = LOG_WARNING;
-               reason = "Failed application of an update diff";
-               if(options & cib_force_diff && cib_is_master == FALSE) {
-                       log_level = LOG_INFO;
-                       reason = "Failed application of a global update.  
Requesting full refresh.";
-                       do_resync = TRUE;
-               } else if(options & cib_force_diff) {
-                       reason = "Failed application of a global update.  Not 
requesting full refresh.";
+       if(apply_diff) {
+               crm_free(*result_cib);
+               *result_cib = NULL;
+               if(apply_xml_diff(existing_cib, input, result_cib) == FALSE) {
+                       log_level = LOG_WARNING;
+                       reason = "Failed application of an update diff";
+                       if(options & cib_force_diff && cib_is_master == FALSE) {
+                               log_level = LOG_INFO;
+                               reason = "Failed application of a global 
update.  Requesting full refresh.";
+                               do_resync = TRUE;
+                       } else if(options & cib_force_diff) {
+                               reason = "Failed application of a global 
update.  Not requesting full refresh.";
+                       }
                }
        }
        
-
        if(reason != NULL) {
                crm_log_maybe(
                        log_level,
@@ -548,13 +550,16 @@
                        result = cib_old_data;
                }
                sync_in_progress = 0;
+               free_xml(*result_cib);
+       START_stat_free_op();
                *result_cib = copy_xml(input);
+       END_stat_free_op();
                send_notify = TRUE;
                
        } else {
                crm_data_t *obj_root = NULL;
-               *result_cib = copy_xml(existing_cib);
                obj_root = get_object_root(section, *result_cib);
+       START_stat_free_op();
                if(replace_xml_child(NULL, obj_root, input, FALSE) == FALSE) {
                        crm_debug_2("No matching object to replace");
                        result = cib_NOTEXISTS;
@@ -565,7 +570,7 @@
                } else if(safe_str_eq(section, XML_CIB_TAG_STATUS)) {
                        send_notify = TRUE;
                }
-               cib_update_counter(*result_cib, XML_ATTR_NUMUPDATES, FALSE);
+       END_stat_free_op();
        }
        
        if(send_notify) {
@@ -591,17 +596,17 @@
                return cib_NOOBJECT;
        }
        
-       *result_cib = copy_xml(existing_cib);
        obj_root = get_object_root(section, *result_cib);
        
        crm_validate_data(input);
        crm_validate_data(*result_cib);
 
+       START_stat_free_op();
        if(replace_xml_child(NULL, obj_root, input, TRUE) == FALSE) {
                crm_debug_2("No matching object to delete");
        }
+       END_stat_free_op();
        
-       cib_update_counter(*result_cib, XML_ATTR_NUMUPDATES, FALSE);
        return cib_ok;
 }
 
@@ -619,17 +624,18 @@
                return cib_NOOBJECT;
        }
        
-       *result_cib = copy_xml(existing_cib);
        obj_root = get_object_root(section, *result_cib);
        
        crm_validate_data(input);
        crm_validate_data(*result_cib);
 
+       START_stat_free_op();
        if(update_xml_child(obj_root, input) == FALSE) {
+               END_stat_free_op();
                return cib_NOTEXISTS;           
        }
+       END_stat_free_op();
        
-       cib_update_counter(*result_cib, XML_ATTR_NUMUPDATES, FALSE);
        return cib_ok;
 }
 
@@ -675,8 +681,6 @@
                return cib_NOOBJECT;
        }
        
-       *result_cib = copy_xml(existing_cib);
-       
        crm_validate_data(input);
        crm_validate_data(*result_cib);
        failed = create_xml_node(NULL, XML_TAG_FAILED);
@@ -696,7 +700,10 @@
                        XML_CIB_TAG_CRMCONFIG
                };
 
+       START_stat_free_op();
                copy_in_properties(*result_cib, input);
+       END_stat_free_op();
+       
                for(lpc = 0; lpc < DIMOF(type_list); lpc++) {
                        type = type_list[lpc];
        
@@ -714,10 +721,6 @@
                        *result_cib, input, failed, cib_update_op, section);
        }
 
-       if(result == cib_ok && !(options & cib_inhibit_bcast)) {
-               cib_update_counter(*result_cib, XML_ATTR_NUMUPDATES, FALSE);
-       }
-       
        if (result != cib_ok || xml_has_children(failed)) {
                if(result == cib_ok) {
                        result = cib_unknown;
@@ -732,6 +735,7 @@
 }
 
 #define cib_update_xml_macro(parent, xml_update)                       \
+       START_stat_free_op();                                           \
        if(operation == CIB_UPDATE_OP_DELETE) {                         \
                rc = delete_cib_object(parent, xml_update);             \
                update_results(failed, xml_update, operation, rc);      \
@@ -743,7 +747,8 @@
        } else {                                                        \
                rc = add_cib_object(parent, xml_update);                \
                update_results(failed, xml_update, operation, rc);      \
-       } 
+       }                                                               \
+       END_stat_free_op();
 
 enum cib_errors
 updateList(crm_data_t *local_cib, crm_data_t *xml_section, crm_data_t *failed,
@@ -812,10 +817,10 @@
 
                add_node_copy(xml_node, target);
                
-               crm_xml_add(xml_node, XML_FAILCIB_ATTR_ID, ID(target));
+               crm_xml_add(xml_node, XML_FAILCIB_ATTR_ID,      ID(target));
                crm_xml_add(xml_node, XML_FAILCIB_ATTR_OBJTYPE, TYPE(target));
-               crm_xml_add(xml_node, XML_FAILCIB_ATTR_OP, operation_msg);
-               crm_xml_add(xml_node, XML_FAILCIB_ATTR_REASON, error_msg);
+               crm_xml_add(xml_node, XML_FAILCIB_ATTR_OP,      operation_msg);
+               crm_xml_add(xml_node, XML_FAILCIB_ATTR_REASON,  error_msg);
 
                crm_warn("Action %s failed: %s (cde=%d)",
                          operation_msg, error_msg, return_code);




------------------------------

_______________________________________________
Linux-ha-cvs mailing list
Linux-ha-cvs@lists.linux-ha.org
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 32, Issue 7
*******************************************

Reply via email to