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


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

Message: 1
Date: Tue,  7 Feb 2006 10:18:25 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: heartbeat by alan from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

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

Dir     : linux-ha/heartbeat


Modified Files:
        hb_uuid.c heartbeat.c 


Log Message:
Added a brand new mechanism for creating child processes to do things for us
to keep us from taking a realtime hit for certain operations.
Initially, this mechanism is being used to write out the host cache data
and also the deleted node cache data - which causes us a realtime hit
when we need to write it out.
This happens on startup and when nodes join or are deleted at runtime.

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/hb_uuid.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- hb_uuid.c   17 Nov 2005 22:42:13 -0000      1.19
+++ hb_uuid.c   7 Feb 2006 17:18:24 -0000       1.20
@@ -606,7 +606,7 @@
 }
 
 
-static int
+int
 write_delnode_file(struct sys_config* cfg)
 {
        const char *    tmpname =       DELHOSTCACHEFILETMP;
@@ -713,8 +713,7 @@
                return HA_FAIL;
        }
        
-       return write_delnode_file(cfg);
-
+       return HA_OK;
 }
 
 int 
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/heartbeat.c,v
retrieving revision 1.494
retrieving revision 1.495
diff -u -3 -r1.494 -r1.495
--- heartbeat.c 7 Feb 2006 10:06:22 -0000       1.494
+++ heartbeat.c 7 Feb 2006 17:18:24 -0000       1.495
@@ -2,7 +2,7 @@
  * TODO:
  * 1) Man page update
  */
-/* $Id: heartbeat.c,v 1.494 2006/02/07 10:06:22 sunjd Exp $ */
+/* $Id: heartbeat.c,v 1.495 2006/02/07 17:18:24 alan Exp $ */
 /*
  * heartbeat: Linux-HA heartbeat code
  *
@@ -339,6 +339,9 @@
 static gboolean                init_deadtime_passed = FALSE;           
 static int                     PrintDefaults = FALSE;
 static int                     WikiOutput = FALSE;
+GTRIGSource*                   write_hostcachefile = NULL;
+GTRIGSource*                   write_delcachefile = NULL;
+
 
 #undef DO_AUDITXMITHIST
 #ifdef DO_AUDITXMITHIST
@@ -359,6 +362,11 @@
 ,                      int exitcode, int waslogged);
 static
 const char*    CoreProcessName(ProcTrack* p);
+static void    TmpProcessRegistered(ProcTrack* p);
+static void    TmpProcessDied(ProcTrack* p, int status, int signo
+,                      int exitcode, int waslogged);
+static
+const char*    TmpProcessName(ProcTrack* p);
 
 void           hb_kill_managed_children(int nsig);
 void           hb_kill_rsc_mgmt_children(int nsig);
@@ -415,6 +423,8 @@
 static void    hb_add_deadtime(int increment);
 static gboolean        hb_pop_deadtime(gpointer p);
 static void    dump_missing_pkts_info(void);
+static gboolean        write_hostcachedata(gpointer ginfo);
+static gboolean        write_delcachedata(gpointer ginfo);
 
 static GHashTable*     message_callbacks = NULL;
 static gboolean        HBDoMsgCallback(const char * type, struct node_info* 
fromnode
@@ -472,6 +482,11 @@
        CoreProcessRegistered,
        CoreProcessName
 };
+static ProcTrack_ops           TmpProcessTrackOps = {
+       TmpProcessDied,
+       TmpProcessRegistered,
+       TmpProcessName
+};
 
 
 static GSourceFuncs            polled_input_SourceFuncs = {
@@ -622,6 +637,83 @@
        }
 }
 
+struct tmpproc_track {
+       const char *    procname;
+       GTRIGSource*    trigger;
+       gboolean        isrunning;
+       gboolean        runagain;
+};
+
+/*
+ *      We make sure only one copy is running at a time.
+ */
+static gboolean
+write_hostcachedata(gpointer ginfo)
+{
+       struct tmpproc_track*   info = ginfo;
+       int                     pid;
+
+       /* Make sure only one copy is running at a time. */
+       /* This avoids possible concurrency problems. */
+       if (info->isrunning) {
+               info->runagain = TRUE;
+               return TRUE;
+       }
+       info->procname  = __FUNCTION__;
+       info->isrunning = TRUE;
+
+       switch ((pid=fork())) {
+               case -1:        cl_perror("%s: Can't fork writeprocess!", 
__FUNCTION__);
+                               return TRUE;
+                               break;
+
+               case 0:         /* Child */
+                               if (write_cache_file(config) == HA_OK) {
+                                       exit(0);
+                               }
+                               exit(1);
+                               break;
+               default:
+                               /* Fall out */;
+
+       }
+       NewTrackedProc(pid, 0, PT_LOGVERBOSE, ginfo,    &TmpProcessTrackOps);
+       return TRUE;
+}
+
+static gboolean
+write_delcachedata(gpointer ginfo)
+{
+       struct tmpproc_track*   info = ginfo;
+       int                     pid;
+
+       /* Make sure only one copy is running at a time. */
+       /* This avoids possible concurrency problems. */
+       if (info->isrunning) {
+               info->runagain = TRUE;
+               return TRUE;
+       }
+       info->procname  = __FUNCTION__;
+       info->isrunning = TRUE;
+
+       switch ((pid=fork())) {
+               case -1:        cl_perror("%s: Can't fork write process!", 
__FUNCTION__);
+                               return TRUE;
+                               break;
+
+               case 0:         /* Child */
+                               if (write_delnode_file(config) == HA_OK) {
+                                       exit(0);
+                               }
+                               exit(1);
+               default:
+                               /* Fall out */;
+
+       }
+       NewTrackedProc(pid, 0, PT_LOGVERBOSE, ginfo, &TmpProcessTrackOps);
+       return TRUE;
+}
+
 void
 hb_setup_child(void)
 {
@@ -754,6 +846,8 @@
        int             pid;
        int             ourproc = 0;
        int     (*getgen)(seqno_t * generation) = IncrGeneration;
+       struct tmpproc_track    hostcache_info;
+       struct tmpproc_track    delcache_info;
 
        localdie = NULL;
 
@@ -780,10 +874,24 @@
                cl_log(LOG_DEBUG, "uuid is:%s", uuid_str);
        }
        
-       /* We only need to add our uuid if it's not already in table */
+       memset(&hostcache_info, 0, sizeof(hostcache_info));
+       write_hostcachefile = G_main_add_TriggerHandler(PRI_WRITECACHE
+       ,       write_hostcachedata, &hostcache_info, NULL);
+       hostcache_info.trigger = write_hostcachefile;
+
+       memset(&delcache_info, 0, sizeof(delcache_info));
+       write_delcachefile = G_main_add_TriggerHandler(PRI_WRITECACHE
+       ,       write_delcachedata, &delcache_info, NULL);
+       hostcache_info.trigger = write_delcachefile;
+
        add_uuidtable(&config->uuid, curnode);
        cl_uuid_copy(&curnode->uuid, &config->uuid);
-       write_cache_file(config);
+
+       /*
+        * We _really_ only need to write out the uuid file if we're not yet
+        * in the host cache file on disk.
+        */
+       G_main_set_trigger(write_hostcachefile);
 
        if (stat(FIFONAME, &buf) < 0 || !S_ISFIFO(buf.st_mode)) {
                cl_log(LOG_INFO, "Creating FIFO %s.", FIFONAME);
@@ -2404,7 +2512,7 @@
                ha_free(nodes[i]);
                nodes[i]=NULL;
        }
-       write_cache_file(config);
+       G_main_set_trigger(write_hostcachefile);
        return;
 }
 
@@ -2526,7 +2634,8 @@
                nodes[i]= NULL; 
        }
        
-       write_cache_file(config);
+       write_delnode_file(config);
+       G_main_set_trigger(write_delcachefile);
        
        return ;
        
@@ -3123,7 +3232,7 @@
                         */
                        thisnode->status_suppressed = TRUE;
                        update_tables(from, &fromuuid);
-                       write_cache_file(config);
+                       G_main_set_trigger(write_hostcachefile);
                        return;
                }
        }
@@ -3311,6 +3420,39 @@
        return (pi ? core_proc_name(pi->type) : "Core heartbeat process");
        
 }
+/***********************************************************************
+ * Track our temporary child processes...
+ ***********************************************************************/
+static void
+TmpProcessRegistered(ProcTrack* p)
+{
+       return;
+}
+static void
+TmpProcessDied(ProcTrack* p, int status, int signo, int exitcode
+,      int waslogged)
+{
+       struct tmpproc_track *  pt = p->privatedata;
+ 
+       pt->isrunning=FALSE;
+       if (pt->runagain) {
+               pt->runagain=FALSE;
+               /*  Do it again! */
+               G_main_set_trigger(pt->trigger);
+               /* Note that we set the trigger for this, we don't
+                * call the function again directly.
+                * This allows the scheduler to have a vote on
+                * when the new fork, etc. happens.
+                */
+       }
+       return;
+}
+static const char *
+TmpProcessName(ProcTrack* p)
+{
+       struct tmpproc_track *  pt = p->privatedata;
+       return pt->procname;
+}
 
 /***********************************************************************
  * Track our managed child processes...
@@ -5025,7 +5167,7 @@
        if (from && !cl_uuid_is_null(&fromuuid)){
                /* We didn't know their uuid before, but now we do... */
                if (update_tables(from, &fromuuid)){
-                       write_cache_file(config);
+                       G_main_set_trigger(write_hostcachefile);
                }
        }
        
@@ -6090,6 +6232,14 @@
 
 /*
  * $Log: heartbeat.c,v $
+ * Revision 1.495  2006/02/07 17:18:24  alan
+ * Added a brand new mechanism for creating child processes to do things for us
+ * to keep us from taking a realtime hit for certain operations.
+ * Initially, this mechanism is being used to write out the host cache data
+ * and also the deleted node cache data - which causes us a realtime hit
+ * when we need to write it out.
+ * This happens on startup and when nodes join or are deleted at runtime.
+ *
  * Revision 1.494  2006/02/07 10:06:22  sunjd
  * make some versions of gcc not complain: used uninitialized
  *




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

Message: 2
Date: Tue,  7 Feb 2006 10:33:31 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: heartbeat by alan from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

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

Dir     : linux-ha/heartbeat


Modified Files:
        heartbeat.c 


Log Message:
Cleaned up (set to NULL) the private data for our hostcache write processes
when they exit so the bad message will go away...

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/heartbeat.c,v
retrieving revision 1.495
retrieving revision 1.496
diff -u -3 -r1.495 -r1.496
--- heartbeat.c 7 Feb 2006 17:18:24 -0000       1.495
+++ heartbeat.c 7 Feb 2006 17:33:30 -0000       1.496
@@ -2,7 +2,7 @@
  * TODO:
  * 1) Man page update
  */
-/* $Id: heartbeat.c,v 1.495 2006/02/07 17:18:24 alan Exp $ */
+/* $Id: heartbeat.c,v 1.496 2006/02/07 17:33:30 alan Exp $ */
 /*
  * heartbeat: Linux-HA heartbeat code
  *
@@ -3445,6 +3445,7 @@
                 * when the new fork, etc. happens.
                 */
        }
+       p->privatedata = NULL;
        return;
 }
 static const char *
@@ -6232,6 +6233,10 @@
 
 /*
  * $Log: heartbeat.c,v $
+ * Revision 1.496  2006/02/07 17:33:30  alan
+ * Cleaned up (set to NULL) the private data for our hostcache write processes
+ * when they exit so the bad message will go away...
+ *
  * Revision 1.495  2006/02/07 17:18:24  alan
  * Added a brand new mechanism for creating child processes to do things for us
  * to keep us from taking a realtime hit for certain operations.




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

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


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

Reply via email to