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 gshi from 
      ([email protected])
   2. Linux-HA CVS: include by gshi from 
      ([email protected])
   3. Linux-HA CVS: lib by gshi from  ([email protected])
   4. Linux-HA CVS: heartbeat by gshi from 
      ([email protected])


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

Message: 1
Date: Tue, 20 Dec 2005 16:32:59 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: heartbeat by gshi from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

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

Dir     : linux-ha/heartbeat


Modified Files:
        hb_rexmit.c 


Log Message:
Use /dev/urandom to generate seed for random()


===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/hb_rexmit.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- hb_rexmit.c 10 Nov 2005 01:34:40 -0000      1.2
+++ hb_rexmit.c 20 Dec 2005 23:32:59 -0000      1.3
@@ -191,7 +191,7 @@
        unsigned long sourceid;
        struct rexmit_info* ri;
        if (delay == 0){
-               srand((int)time_longclock());
+               srand(cl_random());
                delay = (1.0* rand()/RAND_MAX)*MAX_REXMIT_DELAY;
        }
        




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

Message: 2
Date: Tue, 20 Dec 2005 16:32:59 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: include by gshi from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : gshi
Host    : 
Project : linux-ha
Module  : include

Dir     : linux-ha/include/clplumbing


Modified Files:
        cl_misc.h 


Log Message:
Use /dev/urandom to generate seed for random()






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

Message: 3
Date: Tue, 20 Dec 2005 16:33:00 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by gshi from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

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

Dir     : linux-ha/lib/clplumbing


Modified Files:
        cl_misc.c 


Log Message:
Use /dev/urandom to generate seed for random()


===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/clplumbing/cl_misc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- cl_misc.c   16 Dec 2005 02:11:59 -0000      1.6
+++ cl_misc.c   20 Dec 2005 23:32:59 -0000      1.7
@@ -24,6 +24,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <stdio.h>
 
 int
 cl_str_to_boolean(const char * s, int * ret)
@@ -80,3 +81,42 @@
        
        return getenv(env_name);
 }
+
+
+int
+cl_binary_to_int(const char* data, int len)
+{
+       const char *p = data;
+       const char *pmax = p + len;
+       guint h = *p;
+       
+       if (h){
+               for (p += 1; p < pmax; p++){
+                       h = (h << 5) - h + *p;
+               }
+       }
+       
+       return h;
+}
+
+
+int
+cl_random(void)
+{
+       char buf[16];
+       
+       FILE* fs = fopen("/dev/urandom", "r");
+       if (fs == NULL){
+               cl_log(LOG_ERR, "%s: Opening file failed", 
+                      __FUNCTION__);
+               return -1;
+       }
+       
+       if (fread(buf,1, sizeof(buf), fs)!= sizeof(buf)){
+               cl_log(LOG_ERR, "%s: reading file failed",
+                      __FUNCTION__);
+               return -1;
+       }       
+       
+       return cl_binary_to_int(buf, sizeof(buf));
+}




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

Message: 4
Date: Tue, 20 Dec 2005 17:01:51 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: heartbeat by gshi from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

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

Dir     : linux-ha/heartbeat


Modified Files:
        config.c hb_rexmit.c 


Log Message:
make max rexmit delay tunable in ha.cf


===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/config.c,v
retrieving revision 1.189
retrieving revision 1.190
diff -u -3 -r1.189 -r1.190
--- config.c    18 Dec 2005 21:59:12 -0000      1.189
+++ config.c    21 Dec 2005 00:01:51 -0000      1.190
@@ -1,4 +1,4 @@
-/* $Id: config.c,v 1.189 2005/12/18 21:59:12 alan Exp $ */
+/* $Id: config.c,v 1.190 2005/12/21 00:01:51 gshi Exp $ */
 /*
  * Parse various heartbeat configuration files...
  *
@@ -91,6 +91,7 @@
 static int set_compression_threshold(const char *);
 static int set_traditional_compression(const char *);
 static int set_env(const char *);
+static int set_max_rexmit_delay(const char *);
 static int set_generation_method(const char *);
 static int set_realtime(const char *);
 static int set_debuglevel(const char *);
@@ -109,6 +110,8 @@
   static int set_normalpoll(const char *);
 #endif
 
+
+void hb_set_max_rexmit_delay(int);
 /*
  * Each of these parameters is is automatically recorded by
  * SetParameterValue().  They are then passed to the plugins
@@ -159,6 +162,7 @@
 ,{KEY_COMPRESSION_THRESHOLD, set_compression_threshold, TRUE, "2", "set 
compression threshold"}
 ,{KEY_TRADITIONAL_COMPRESSION, set_traditional_compression, TRUE, "yes", "set 
traditional_compression"}
 ,{KEY_ENV, set_env, FALSE, NULL, "set environment variable"}
+,{KEY_MAX_REXMIT_DELAY, set_max_rexmit_delay, TRUE,"250", "set the maximum 
rexmit delay time"}
 };
 
 static const struct WholeLineDirective {
@@ -2143,9 +2147,25 @@
        if (ANYDEBUG){
                cl_log(LOG_DEBUG, "setting env(%s=%s), nvpair(%s)", env_name, 
value,nvpair);
        }
+       
        return HA_OK;
 }
+static int
+set_max_rexmit_delay(const char * value)
+{
+       int foo;
+
+       foo =  atoi(value);
+       if (foo <= 0){
+               cl_log(LOG_ERR, "Invalid max_rexmit_delay time(%s)",
+                      value);
+               return HA_FAIL;
+       }
+       
+       hb_set_max_rexmit_delay(foo);
 
+       return HA_OK;
+}
 
 #if 0
 static void
@@ -2459,6 +2479,9 @@
 
 /*
  * $Log: config.c,v $
+ * Revision 1.190  2005/12/21 00:01:51  gshi
+ * make max rexmit delay tunable in ha.cf
+ *
  * Revision 1.189  2005/12/18 21:59:12  alan
  * Changed some comments generated when printing default values.
  *
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/hb_rexmit.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- hb_rexmit.c 20 Dec 2005 23:32:59 -0000      1.3
+++ hb_rexmit.c 21 Dec 2005 00:01:51 -0000      1.4
@@ -37,14 +37,32 @@
 
 static void    schedule_rexmit_request(struct node_info* node, seqno_t seq, 
int delay);
 
-#define MAX_REXMIT_DELAY       250
+static int max_rexmit_delay = 250;
 static GHashTable*             rexmit_hash_table = NULL;
+void hb_set_max_rexmit_delay(int);
+
 
 struct rexmit_info{
        seqno_t seq;
        struct node_info* node;
 };
 
+void
+hb_set_max_rexmit_delay(int value)
+{
+       if (value <= 0){
+               cl_log(LOG_ERR, "%s: invalid value (%d)",
+                      __FUNCTION__, value);
+               return;
+       }
+       if (ANYDEBUG){
+               cl_log(LOG_DEBUG, "Setting max_rexmit_delay to %d ms", 
+                      value);
+       }
+       max_rexmit_delay =value;
+       
+       return;
+}
 static guint
 rexmit_hash_func(gconstpointer key)
 {
@@ -180,7 +198,7 @@
                return FALSE;
        }
        
-       schedule_rexmit_request(node, seq, MAX_REXMIT_DELAY);
+       schedule_rexmit_request(node, seq, max_rexmit_delay);
        
        return FALSE;
 }
@@ -192,7 +210,7 @@
        struct rexmit_info* ri;
        if (delay == 0){
                srand(cl_random());
-               delay = (1.0* rand()/RAND_MAX)*MAX_REXMIT_DELAY;
+               delay = (1.0* rand()/RAND_MAX)*max_rexmit_delay;
        }
        
        ri = ha_malloc(sizeof(struct rexmit_info));




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

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


End of Linux-ha-cvs Digest, Vol 25, Issue 48
********************************************

Reply via email to