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: lib by alan from  ([email protected])
   2. Linux-HA CVS: crm by andrew from 
      ([email protected])


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

Message: 1
Date: Tue, 17 Jan 2006 13:56:52 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by alan from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

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

Dir     : linux-ha/lib/hbclient


Modified Files:
        client_lib.c 


Log Message:
Put in a patch which should allow clients to read unread msgs from a
heartbeat channel even after they disconnected - provided they didn't
destroy the channel...

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/hbclient/client_lib.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -3 -r1.35 -r1.36
--- client_lib.c        17 Jan 2006 17:44:39 -0000      1.35
+++ client_lib.c        17 Jan 2006 20:56:52 -0000      1.36
@@ -1,4 +1,4 @@
-/* $Id: client_lib.c,v 1.35 2006/01/17 17:44:39 alan Exp $ */
+/* $Id: client_lib.c,v 1.36 2006/01/17 20:56:52 alan Exp $ */
 /* 
  * client_lib: heartbeat API client side code
  *
@@ -455,7 +455,7 @@
        }
        pi = (llc_private_t*)cinfo->ll_cluster_private;
 
-       if (!pi->SignedOn) {
+       if (!pi->SignedOn || !pi->chan) {
                /* Already signed off... No value in returning an error... */
                return HA_OK;
        }
@@ -476,6 +476,7 @@
        OurClientID = NULL;
        if(need_destroy_chan){
                pi->chan->ops->destroy(pi->chan);
+               pi->chan = NULL;
        }
        pi->SignedOn = 0;
        zap_order_seq(pi);
@@ -1543,7 +1544,7 @@
                const char *    type;
                
                pi->chan->ops->waitin(pi->chan);
-               if (pi->chan->ch_status  == IPC_DISCONNECT){
+               if (!IPC_ISRCONN(pi->chan)){
                        break;
                }
                if ((msg=msgfromIPC(pi->chan, 0)) == NULL) {
@@ -2032,7 +2033,7 @@
        }
        pi = (llc_private_t*)llc->ll_cluster_private;
 
-       if (!pi->SignedOn) {
+       if (!pi->chan) {
                return NULL;
        }
 
@@ -2065,10 +2066,10 @@
                }               
        }
        /* Process msg from channel */
-       while (msgready(llc)){
+       while (pi->chan && msgready(llc)){
                msg = msgfromIPC(pi->chan, 0);
                if (msg == NULL) {
-                       if (pi->chan->ch_status != IPC_CONNECT) {
+                       if (!IPC_ISRCONN(pi->chan)) {
                                pi->SignedOn = FALSE;
                                return NULL;
                        }
@@ -2084,11 +2085,11 @@
        /* If this is a blocking call, we keep on reading from channel, so
          * that we can finally return a non-NULL msg to user.
          */
-       for(;;) {
+       for(;pi->chan;) {
                pi->chan->ops->waitin(pi->chan);
                msg = msgfromIPC(pi->chan, 0);
                if (msg == NULL) {
-                       if (pi->chan->ch_status != IPC_CONNECT) {
+                       if (!IPC_ISRCONN(pi->chan)) {
                                pi->SignedOn = FALSE;
                        }
                        return NULL;
@@ -2097,6 +2098,7 @@
                        return retmsg;
                }
        }
+       return NULL;
 }
 
 /*
@@ -2269,7 +2271,7 @@
        }
        pi = (llc_private_t*) llc->ll_cluster_private;
 
-       if (!pi->SignedOn) {
+       if (!pi->chan) {
                ha_api_log(LOG_ERR, "read_msg_w_callbacks: Not signed on");
                return NULL;
        }
@@ -2452,7 +2454,7 @@
                return(-1);
        }
        pi = (llc_private_t*)ci->ll_cluster_private;
-       if (!pi->SignedOn) {
+       if (!pi->chan) {
                ha_api_log(LOG_ERR, "not signed on");
                return -1;
        }
@@ -2471,9 +2473,8 @@
                return NULL;
        }
        pi = (llc_private_t*)ci->ll_cluster_private;
-       if (!pi->SignedOn) {
+       if (!pi->chan) {
                ha_api_log(LOG_ERR, "not signed on");
-               return NULL;
        }
        return pi->chan;
 }
@@ -2495,15 +2496,20 @@
        }
        pi = (llc_private_t*)ci->ll_cluster_private;
 
-       if (!pi->SignedOn) {
-               ha_api_log(LOG_ERR, "not signed on");
-               return 0;
-       }
        if (pi->firstQdmsg) {
                return 1;
        }
+       if (!pi->chan) {
+               ha_api_log(LOG_ERR, "msgready: signed off");
+               return 0;
+       }
 
-       return pi->chan->ops->is_message_pending(pi->chan);
+       if (IPC_ISRCONN(pi->chan)) {
+               return pi->chan->ops->is_message_pending(pi->chan);
+       }else{
+               ha_api_log(LOG_ERR, "msgready: EOF from heartbeat");
+               return 0;
+       }
 }
 
 /*
@@ -3010,11 +3016,11 @@
        pi  = (llc_private_t*) lcl->ll_cluster_private;
        
        if (pi->chan == NULL){
-               cl_log(LOG_ERR, "Invalid argument: chan is NULL");
+               cl_log(LOG_ERR, "closed channel");
                return FALSE;
        }
        
-       return (pi->chan->ch_status == IPC_CONNECT);    
+       return (IPC_ISRCONN(pi->chan));
 }
 
 




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

Message: 2
Date: Tue, 17 Jan 2006 14:47:28 -0700 (MST)
From: [email protected]
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/crmd


Modified Files:
        callbacks.c 


Log Message:
Overhaul of IPC and HA channel callbacks

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/crmd/callbacks.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -3 -r1.99 -r1.100
--- callbacks.c 13 Jan 2006 19:04:12 -0000      1.99
+++ callbacks.c 17 Jan 2006 21:47:28 -0000      1.100
@@ -50,35 +50,51 @@
 /* #define MAX_EMPTY_CALLBACKS 20 */
 /* int empty_callbacks = 0; */
 
+#define trigger_fsa(source) crm_debug_3("Triggering FSA: %s", __FUNCTION__); \
+       G_main_set_trigger(source);
+
 gboolean
 crmd_ha_msg_dispatch(IPC_Channel *channel, gpointer user_data)
 {
-       int lpc = 0;
+       gboolean stay_connected = TRUE;
        ll_cluster_t *hb_cluster = (ll_cluster_t*)user_data;
 
-       while(lpc < 2 && hb_cluster->llc_ops->msgready(hb_cluster)) {
-               if(channel->ch_status != IPC_CONNECT) {
-                       /* there really is no point continuing */
-                       break;
+       crm_debug_3("Invoked");
+       if(IPC_ISRCONN(channel)) {
+               if(hb_cluster->llc_ops->msgready(hb_cluster) == 0) {
+                       crm_debug_2("no message ready yet");
                }
-               lpc++; 
                /* invoke the callbacks but dont block */
                hb_cluster->llc_ops->rcvmsg(hb_cluster, 0);
        }
-
-       crm_debug_3("%d HA messages dispatched", lpc);
-       G_main_set_trigger(fsa_source);
        
-       if (channel && (channel->ch_status != IPC_CONNECT)) {
+       if (channel->ch_status != IPC_CONNECT) {
                if(is_set(fsa_input_register, R_HA_DISCONNECTED) == FALSE) {
                        crm_crit("Lost connection to heartbeat service.");
+               } else {
+                       crm_info("Lost connection to heartbeat service.");
                }
-               return FALSE;
+               trigger_fsa(fsa_source);
+               stay_connected = FALSE;
        }
     
-       return TRUE;
+       return stay_connected;
 }
 
+void
+crmd_ha_connection_destroy(gpointer user_data)
+{
+       crm_debug_3("Invoked");
+       if(is_set(fsa_input_register, R_HA_DISCONNECTED)) {
+               /* we signed out, so this is expected */
+               crm_info("Connection to heartbeat service disconnected.");
+               return;
+       }
+
+       crm_crit("Lost connection to heartbeat service.");
+       register_fsa_input(C_HA_DISCONNECT, I_ERROR, NULL);     
+       trigger_fsa(fsa_source);
+}
 
 void
 crmd_ha_msg_callback(HA_Message * msg, void* private_data)
@@ -176,10 +192,13 @@
 #endif
 
        delete_ha_msg_input(new_input);
+       trigger_fsa(fsa_source);
 
        return;
 }
 
+
+
 /*
  * Apparently returning TRUE means "stay connected, keep doing stuff".
  * Returning FALSE means "we're all done, close the connection"
@@ -193,16 +212,14 @@
        crmd_client_t *curr_client = (crmd_client_t*)user_data;
        gboolean stay_connected = TRUE;
        
-       crm_debug_2("Processing IPC message from %s",
+       crm_debug_2("Invoked: %s",
                   curr_client->table_key);
 
-       while(lpc == 0 && client->ops->is_message_pending(client)) {
-               if (client->ch_status == IPC_DISCONNECT) {
-                       /* The message which was pending for us is that
-                        * the IPC status is now IPC_DISCONNECT */
+       while(IPC_ISRCONN(client)) {
+               if(client->ops->is_message_pending(client) == 0) {
                        break;
-               }
-               if (client->ops->recv(client, &msg) != IPC_OK) {
+
+               } else if (client->ops->recv(client, &msg) != IPC_OK) {
                        perror("Receive failure:");
                        crm_err("[%s] [receive failure]",
                                curr_client->table_key);
@@ -228,21 +245,26 @@
                
                msg = NULL;
                new_input = NULL;
+
+               if(client->ch_status != IPC_CONNECT) {
+                       break;
+               }
        }
        
        crm_debug_2("Processed %d messages", lpc);
     
-       if (client->ch_status == IPC_DISCONNECT) {
+       if (client->ch_status != IPC_CONNECT) {
                stay_connected = FALSE;
                process_client_disconnect(curr_client);
        }
 
-       G_main_set_trigger(fsa_source);
+       trigger_fsa(fsa_source);
        return stay_connected;
 }
 
 
 
+
 gboolean
 lrm_dispatch(IPC_Channel *src_not_used, gpointer user_data)
 {
@@ -250,12 +272,12 @@
        ll_lrm_t *lrm = (ll_lrm_t*)user_data;
        IPC_Channel *lrm_channel = lrm->lrm_ops->ipcchan(lrm);
 
-       crm_debug_3("received callback");
+       crm_debug_3("Invoked");
        lrm->lrm_ops->rcvmsg(lrm, FALSE);
 
        if(lrm_channel->ch_status != IPC_CONNECT) {
                if(is_set(fsa_input_register, R_LRM_CONNECTED)) {
-                       crm_err("LRM Connection failed");
+                       crm_crit("LRM Connection failed");
                        register_fsa_input(C_FSA_INTERNAL, I_ERROR, NULL);
                        clear_bit_inplace(fsa_input_register, R_LRM_CONNECTED);
 
@@ -276,7 +298,7 @@
                return;
        }
        
-       crm_debug_2("received callback: %s/%s (%s)",
+       crm_debug_3("Invoked: %s/%s (%s)",
                    op->op_type, op->rsc_id, op_status2text(op->op_status));
 
        /* Make sure the LRM events are received in order */
@@ -289,7 +311,6 @@
 {
        crm_data_t *update = NULL;
 
-       crm_debug_3("received callback");
        crm_notice("Status update: Node %s now has status [%s]",node,status);
 
        if(safe_str_neq(status, DEADSTATUS)) {
@@ -305,7 +326,7 @@
 
        /* this change should not be broadcast */
        update_local_cib(create_cib_fragment(update, XML_CIB_TAG_STATUS));
-       G_main_set_trigger(fsa_source);
+       trigger_fsa(fsa_source);
        free_xml(update);
 }
 
@@ -318,7 +339,7 @@
        crm_data_t *update = NULL;
        gboolean clear_shutdown = FALSE;
        
-       crm_debug_3("received callback");
+       crm_debug_3("Invoked");
        if(safe_str_neq(client, CRM_SYSTEM_CRMD)) {
                return;
        }
@@ -387,27 +408,14 @@
                }
        }
        
-       G_main_set_trigger(fsa_source);
-}
-
-void
-crmd_ha_connection_destroy(gpointer user_data)
-{
-       if(is_set(fsa_input_register, R_HA_DISCONNECTED)) {
-               /* we signed out, so this is expected */
-               return;
-       }
-
-       crm_crit("Heartbeat has left us");
-       /* this is always an error */
-       /* feed this back into the FSA */
-       register_fsa_input(C_HA_DISCONNECT, I_ERROR, NULL);
+       trigger_fsa(fsa_source);
 }
 
 
 gboolean
 crmd_client_connect(IPC_Channel *client_channel, gpointer user_data)
 {
+       crm_debug_3("Invoked");
        if (client_channel == NULL) {
                crm_err("Channel was NULL");
 
@@ -448,7 +456,7 @@
        oc_ev_t *ccm_token = (oc_ev_t*)user_data;
        gboolean was_error = FALSE;
        
-       crm_debug_3("received callback");       
+       crm_debug_3("Invoked");
        rc = oc_ev_handle_event(ccm_token);
 
        if(rc != 0) {
@@ -461,7 +469,7 @@
                was_error = TRUE;
        }
 
-       G_main_set_trigger(fsa_source);
+       trigger_fsa(fsa_source);
        return !was_error;
 }
 
@@ -479,7 +487,7 @@
        gboolean update_quorum = FALSE;
        gboolean trigger_transition = FALSE;
 
-       crm_debug_3("received callback");
+       crm_debug_3("Invoked");
 
        if(data != NULL) {
                instance = membership->m_instance;
@@ -586,6 +594,9 @@
 void
 crmd_cib_connection_destroy(gpointer user_data)
 {
+       crm_debug_3("Invoked");
+       trigger_fsa(fsa_source);
+
        if(is_set(fsa_input_register, R_CIB_CONNECTED) == FALSE) {
                crm_info("Connection to the CIB terminated...");
                return;
@@ -610,6 +621,7 @@
        if(fsa_diff_max_ms > 0) {
                fsa_start = time_longclock();
        }
+       crm_debug_3("Invoked");
        s_crmd_fsa(C_FSA_INTERNAL);
        if(fsa_diff_max_ms > 0) {
                fsa_stop = time_longclock();




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

_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 26, Issue 42
********************************************

Reply via email to