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


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

Message: 1
Date: Sun, 18 Jun 2006 23:03:16 -0600 (MDT)
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:
(bug1318)Add to send back a confirmation of setting up the callback channel
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/fencing/stonithd/stonithd.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -3 -r1.94 -r1.95
--- stonithd.c  18 Jun 2006 16:57:04 -0000      1.94
+++ stonithd.c  19 Jun 2006 05:03:15 -0000      1.95
@@ -1,4 +1,4 @@
-/* $Id: stonithd.c,v 1.94 2006/06/18 16:57:04 sunjd Exp $ */
+/* $Id: stonithd.c,v 1.95 2006/06/19 05:03:15 sunjd Exp $ */
 
 /* File: stonithd.c
  * Description: STONITH daemon for node fencing
@@ -1367,15 +1367,24 @@
 static gboolean
 accept_client_connect_callback(IPC_Channel * ch, gpointer user)
 {
+       struct ha_msg * reply = NULL;
        stonithd_client_t * signed_client = NULL;
+       const char * api_reply = ST_APIOK;
+
+       stonithd_log2(LOG_DEBUG, "IPC accepted a callback connection.");
 
        if (ch == NULL) {
-               stonithd_log(LOG_ERR, "IPC accepting a connection failed.");
-               return FALSE;
+               stonithd_log(LOG_ERR, "%s:%d: ch==NULL."
+                            , __FUNCTION__, __LINE__);
+               return TRUE;
+       }
+
+       if (ch->ch_status == IPC_DISCONNECT) {
+               stonithd_log(LOG_WARNING
+                       , "callback IPC disconneted with a client: ch=%p", ch);
+               return TRUE;
        }
 
-       stonithd_log2(LOG_DEBUG, "IPC accepted a callback connection.");
-       
        signed_client = find_client_by_farpid(client_list, ch->farside_pid);
        if (signed_client != NULL) {
                if (signed_client->cbch != NULL) {
@@ -1393,8 +1402,30 @@
                stonithd_log(LOG_ERR
                             , "%s:%d: Cannot find a signed client pid=%d"
                             , __FUNCTION__, __LINE__, ch->farside_pid);
+               api_reply = ST_BADREQ;
        }
 
+       if ((reply = ha_msg_new(1)) == NULL) {
+               stonithd_log(LOG_ERR, "%s:%d:ha_msg_new:out of memory."
+                               ,__FUNCTION__, __LINE__);
+               return TRUE;
+       }
+
+       if ( (ha_msg_add(reply, F_STONITHD_TYPE, ST_APIRPL) != HA_OK ) 
+           ||(ha_msg_add(reply, F_STONITHD_APIRPL, ST_RSIGNON) != HA_OK ) 
+           ||(ha_msg_add(reply, F_STONITHD_APIRET, api_reply) != HA_OK ) ) {
+               ZAPMSG(reply);
+               stonithd_log(LOG_ERR, "%s:%d: cannot add field."
+                            , __FUNCTION__, __LINE__);
+               return TRUE;
+       }
+       
+       if (msg2ipcchan(reply, ch) != HA_OK) {
+               stonithd_log(LOG_ERR
+                           , "Failed to reply sign message to callback IPC");
+       }
+
+       ZAPMSG(reply);
        return TRUE;
 }
 
@@ -3053,7 +3084,7 @@
                g_free(client->removereason);
                client->removereason = NULL;
        }
-       
+
        /* don not need to destroy them! */
        client->ch = NULL;
 
@@ -3062,7 +3093,7 @@
                client->cbch = NULL;
        } else {
                stonithd_log(LOG_ERR, "%s:%d: client->cbch = NULL"
-                            , __FUNCTION__, __LINE__);
+                            , __FUNCTION__, __LINE__);
        }
 
        g_free(client);
@@ -3553,6 +3584,9 @@
 
 /* 
  * $Log: stonithd.c,v $
+ * Revision 1.95  2006/06/19 05:03:15  sunjd
+ * (bug1318)Add to send back a confirmation of setting up the callback channel
+ *
  * Revision 1.94  2006/06/18 16:57:04  sunjd
  * fix a memory leak; tweak log to catch errors better
  *




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

Message: 2
Date: Sun, 18 Jun 2006 23:13:34 -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:
(bug1318)Add to receive a confirmation of setting up the callback channel
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/fencing/stonithd_lib.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- stonithd_lib.c      15 Jun 2006 10:46:38 -0000      1.25
+++ stonithd_lib.c      19 Jun 2006 05:13:34 -0000      1.26
@@ -84,7 +84,7 @@
 int
 stonithd_signon(const char * client_name)
 {
-       int rc = ST_FAIL;
+       int     rc = ST_FAIL;
        char    path[] = IPC_PATH_ATTR;
        char    sock[] = STONITHD_SOCK;
        char    cbsock[] = STONITHD_CALLBACK_SOCK;
@@ -152,6 +152,7 @@
        do { 
                rc_tmp= chan_waitout_timeout(chan, DEFAULT_TIMEOUT);
        } while (rc_tmp == IPC_INTR);
+
        if (IPC_OK != rc_tmp) {
                stdlib_log(LOG_ERR, "%s:%d: waitout failed."
                           , __FUNCTION__, __LINE__);
@@ -185,33 +186,69 @@
                                   "stonithd.");
                }
        } else {
-               stdlib_log(LOG_DEBUG, "stonithd_signon: "
+               stdlib_log(LOG_ERR, "stonithd_signon: "
                           "Got an unexpected message.");
-               /* Handle it furtherly ? */
        }
+       ZAPMSG(reply);
 
+       if (ST_OK != rc) { /* Something wrong when try to sign on to stonithd */
+               stonithd_signoff();
+               return rc;
+       }
 
-       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);
+       /* 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 via callback channel */
+       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.");
+               stonithd_signoff();
+               return ST_FAIL;
+       }
+
+        if (cbchan->ops->initiate_connection(cbchan) != IPC_OK) {
+               stdlib_log(LOG_ERR, "stonithd_signon: Can't initiate "
+                          "connection with the callback channel");
+               stonithd_signoff();
+                return ST_FAIL;
+       }
+
+       if ( (reply = msgfromIPC_noauth(cbchan)) == NULL ) {
+               stdlib_log(LOG_ERR, "%s:%d: failed to fetch reply via the "
+                          " callback channel"
+                          , __FUNCTION__, __LINE__);
+               stonithd_signoff();
+               return ST_FAIL;
+       }
        
-               if (cbchan == NULL) {
-                       stdlib_log(LOG_ERR, "stonithd_signon: Can't construct "
-                                  "callback channel to stonithd.");
-                       return ST_FAIL;
+       if ( TRUE == is_expected_msg(reply, F_STONITHD_TYPE, ST_APIRPL, 
+                            F_STONITHD_APIRPL, ST_RSIGNON) ) {
+               if ( ((tmpstr=cl_get_string(reply, F_STONITHD_APIRET)) != NULL)
+                   && (STRNCMP_CONST(tmpstr, ST_APIOK) == 0) ) {
+                       rc = ST_OK;
+                       stdlib_log(LOG_DEBUG, "%s:%d: Got a good signon reply "
+                                 "via the callback channel."
+                                  , __FUNCTION__, __LINE__);
+               } else {
+                       stdlib_log(LOG_WARNING, "%s:%d: Got a bad signon reply "
+                                 "via the callback channel."
+                                  , __FUNCTION__, __LINE__);
                }
+       } else {
+               stdlib_log(LOG_ERR, "stonithd_signon: "
+                          "Got an unexpected message via the callback chan.");
+       }
+       ZAPMSG(reply);
 
-               if (cbchan->ops->initiate_connection(cbchan) != IPC_OK) {
-                       stdlib_log(LOG_ERR, "stonithd_signon: Can't initiate "
-                                  "connection with callback channel");
-                       return ST_FAIL;
-                       }
+       /* Something wrong when try to sign to stonithd via callback channel */
+       if (ST_OK != rc) {
+               stonithd_signoff();
        }
 
-       ZAPMSG(reply);
        return rc;
 }
 
@@ -275,6 +312,15 @@
        }
        ZAPMSG(reply);
        
+       if (NULL != chan) {
+               chan->ops->destroy(chan);
+               chan = NULL;
+       }
+       if (NULL != cbchan) {
+               cbchan->ops->destroy(cbchan);
+               cbchan = NULL;
+       }
+       
        return rc;
 }
 
@@ -855,14 +901,18 @@
                        stdlib_log(LOG_DEBUG, "%s = %s.", field_name2, tmpstr);
                        rc= TRUE;
                } else {
-                       stdlib_log(LOG_NOTICE, "filed <%s> content is <%s>"
+                       stdlib_log(LOG_NOTICE, "field <%s> content is <%s>, "
+                                  "expected content is: <%s>"
                                   , field_name2
-                                  , (NULL == tmpstr) ? "NULL" : tmpstr);
+                                  , (NULL == tmpstr) ? "NULL" : tmpstr
+                                  , field_content2);
                }
        } else {
-               stdlib_log(LOG_NOTICE, "filed <%s> content is <%s>"
+               stdlib_log(LOG_NOTICE, "field <%s> content is <%s>, "
+                          "expected content is: <%s>"
                           , field_name1
-                          , (NULL == tmpstr) ? "NULL" : tmpstr);
+                          , (NULL == tmpstr) ? "NULL" : tmpstr
+                          , field_content1);
        }
 
        return rc;




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

_______________________________________________
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 58
********************************************

Reply via email to