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 sunjd from  ([email protected])


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

Message: 1
Date: Thu, 15 Jun 2006 04:46:39 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by sunjd from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

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

Dir     : linux-ha/lib/fencing


Modified Files:
        stonithd_lib.c 


Log Message:
bug1272: add a channel for callback functions
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/fencing/stonithd_lib.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- stonithd_lib.c      15 Jun 2006 09:20:23 -0000      1.24
+++ stonithd_lib.c      15 Jun 2006 10:46:38 -0000      1.25
@@ -47,6 +47,7 @@
 static char CLIENT_PID_STR[16];
 static gboolean DEBUG_MODE        = FALSE;
 static IPC_Channel * chan         = NULL;
+static IPC_Channel * cbchan       = NULL;
 
 static gboolean INT_BY_ALARM = FALSE;
 static unsigned int DEFAULT_TIMEOUT = 6;
@@ -86,6 +87,7 @@
        int rc = ST_FAIL;
        char    path[] = IPC_PATH_ATTR;
        char    sock[] = STONITHD_SOCK;
+       char    cbsock[] = STONITHD_CALLBACK_SOCK;
        struct  ha_msg * request;
        struct  ha_msg * reply;
        GHashTable *     wchanattrs;
@@ -188,6 +190,27 @@
                /* Handle it furtherly ? */
        }
 
+
+       if (ST_OK == rc) { /* Signed on to stonithd daemon */
+               wchanattrs = g_hash_table_new(g_str_hash, g_str_equal);
+               g_hash_table_insert(wchanattrs, path, cbsock);
+               /* Connect to the stonith deamon */
+               cbchan = ipc_channel_constructor(IPC_ANYTYPE, wchanattrs);
+               g_hash_table_destroy(wchanattrs);
+       
+               if (cbchan == NULL) {
+                       stdlib_log(LOG_ERR, "stonithd_signon: Can't construct "
+                                  "callback channel to stonithd.");
+                       return ST_FAIL;
+               }
+
+               if (cbchan->ops->initiate_connection(cbchan) != IPC_OK) {
+                       stdlib_log(LOG_ERR, "stonithd_signon: Can't initiate "
+                                  "connection with callback channel");
+                       return ST_FAIL;
+                       }
+       }
+
        ZAPMSG(reply);
        return rc;
 }
@@ -258,11 +281,11 @@
 IPC_Channel *
 stonithd_input_IPC_channel(void)
 {
-       if ( chan == NULL || chan->ch_status == IPC_DISCONNECT ) {
+       if ( cbchan == NULL || cbchan->ch_status == IPC_DISCONNECT ) {
                stdlib_log(LOG_ERR, "stonithd_input_IPC_channel: not signon.");
                return NULL;
        } else {
-               return chan;
+               return cbchan;
        }
 }
 
@@ -358,7 +381,7 @@
 gboolean 
 stonithd_op_result_ready(void)
 {
-       if ( chan == NULL || chan->ch_status == IPC_DISCONNECT ) {
+       if ( cbchan == NULL || cbchan->ch_status == IPC_DISCONNECT ) {
                stdlib_log(LOG_ERR, "stonithd_op_result_ready: "
                           "failed due to not on signon status.");
                return FALSE;
@@ -369,8 +392,8 @@
         * from the possible endless waiting. That can be caused by the way
         * in which the caller uses it.
         */
-       return (chan->ops->is_message_pending(chan)
-               || chan->ch_status == IPC_DISCONNECT);
+       return (cbchan->ops->is_message_pending(cbchan)
+               || cbchan->ch_status == IPC_DISCONNECT);
 }
 
 int
@@ -392,12 +415,12 @@
 
        if (stonithd_op_result_ready() == FALSE) {
        /* at that time, blocking must be TRUE */
-               if (IPC_OK != chan->ops->waitin(chan)) {
+               if (IPC_OK != cbchan->ops->waitin(cbchan)) {
                        return ST_FAIL;
                }
        }
 
-       reply = msgfromIPC_noauth(chan);
+       reply = msgfromIPC_noauth(cbchan);
        if ( TRUE == is_expected_msg(reply, F_STONITHD_TYPE, ST_APIRPL, 
                             F_STONITHD_APIRPL, ST_STRET)  ) {
                stonith_ops_t * st_op = NULL;
@@ -583,7 +606,7 @@
 int
 stonithd_set_stonith_ops_callback(stonith_ops_callback_t callback)
 {
-       if ( chan == NULL || chan->ch_status == IPC_DISCONNECT ) {
+       if ( cbchan == NULL || cbchan->ch_status == IPC_DISCONNECT ) {
                stdlib_log(LOG_ERR, "stonithd_set_stonith_ops_callback: "\
                 "failed due to not on signon status.");
                return ST_FAIL;
@@ -696,7 +719,7 @@
 stonithd_set_stonithRA_ops_callback(stonithRA_ops_callback_t callback,
                                    void * private_data)
 {
-       if ( chan == NULL || chan->ch_status == IPC_DISCONNECT ) {
+       if ( cbchan == NULL || cbchan->ch_status == IPC_DISCONNECT ) {
                stdlib_log(LOG_ERR, "stonithd_set_stonithRA_ops_callback: "
                 "failed due to not on signon status.");
                return ST_FAIL;




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

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


End of Linux-ha-cvs Digest, Vol 31, Issue 49
********************************************

Reply via email to