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: heartbeat by alan from
([email protected])
3. Linux-HA CVS: include by alan from
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Sun, 5 Feb 2006 21:52:11 -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/clplumbing
Modified Files:
Makefile.am cl_misc.c
Added Files:
cl_random.c
Log Message:
Random number changes.
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/clplumbing/Makefile.am,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- Makefile.am 9 Dec 2005 20:15:31 -0000 1.45
+++ Makefile.am 6 Feb 2006 04:52:11 -0000 1.46
@@ -48,6 +48,7 @@
cl_msg_types.c \
cl_netstring.c \
cl_poll.c \
+ cl_random.c \
cl_signal.c \
cl_syslog.c \
coredumps.c \
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/clplumbing/cl_misc.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- cl_misc.c 26 Jan 2006 11:52:21 -0000 1.8
+++ cl_misc.c 6 Feb 2006 04:52:11 -0000 1.9
@@ -104,94 +104,3 @@
return h;
}
-
-/* Used to provide seed to the random number generator */
-int
-cl_random(void)
-{
- char buf[16];
- FILE* fs;
- struct timeval tv;
- long horrid;
-
- /*
- * Notes, based on reading of man pages of Solaris, FreeBSD and Linux,
- * and on proof-of-concept tests on Solaris and Linux (32- and 64-bit).
- *
- * Reminder of a subtlety: our intention is not to return a random
- * number, but rather to return a random-enough seed for future
- * random numbers. So don't bother trying (e.g.) "rand()" and
- * "random()".
- *
- * /dev/random and dev/urandom seem to be a related pair. In the
- * words of the song: "You can't have one without the other".
- *
- * /dev/random is probably the best. But it can block. The Solaris
- * implementation can apparently honour "O_NONBLOCK" and "O_NDELAY".
- * But can others? For this reason, I chose not to use it at present.
- *
- * /dev/urandom (with the "u") is also good. This doesn't block.
- * But some OSes may lack it. It is tempting to detect its presence
- * with autoconf and use the result in a "hash-if" here. BUT... in
- * at least one OS, its presence can vary depending upon patch levels,
- * so a binary/package built on an enabled machine might hit trouble
- * when run on one where it is absent. (And vice versa: a build on a
- * disabled machine would be unable to take advantage of it on an
- * enabled machine.) Therefore always try for it at run time.
- *
- * "gettimeofday()" returns a random-ish number in its millisecond
- * component.
- *
- * -- David Lee, Jan 2006
- */
-
- /*
- * Each block below is logically of the form:
- * if good-feature appears present {
- * try feature
- * if feature worked {
- * return its result
- * }
- * }
- * -- fall through to not-quite-so-good feature --
- */
-
- /*
- * Does "/dev/urandom" work?
- */
- fs = fopen("/dev/urandom", "r");
- if (fs == NULL) {
- cl_log(LOG_INFO, "%s: Opening file /dev/urandom failed",
- __FUNCTION__);
- }
- else {
- if (fread(buf,1, sizeof(buf), fs)!= sizeof(buf)){
- cl_log(LOG_INFO, "%s: reading file /dev/urandom failed",
- __FUNCTION__);
- }
- else {
- return cl_binary_to_int(buf, sizeof(buf));
- }
- }
-
- /*
- * Try "gettimeofday()"; use its microsecond output.
- * (Might it be prudent to let, say, the seconds further adjust this,
- * in case * the microseconds are too predictable?)
- */
- if (gettimeofday(&tv, NULL) != 0) {
- cl_log(LOG_INFO, "%s: gettimeofday failed",
- __FUNCTION__);
- }
- else {
- return tv.tv_usec;
- }
-
- /*
- * If all else has failed, return (as a number) the address of
- * something on the stack.
- * Poor, but at least it has a chance of some sort of variability.
- */
- horrid = (long) &tv;
- return (int) horrid;
-}
------------------------------
Message: 2
Date: Sun, 5 Feb 2006 21:55:19 -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_rexmit.c
Log Message:
Marked retransmit timers to check for delays.
Changed to new random number generation mechanism...
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/hb_rexmit.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- hb_rexmit.c 2 Feb 2006 22:30:30 -0000 1.5
+++ hb_rexmit.c 6 Feb 2006 04:55:19 -0000 1.6
@@ -20,7 +20,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-
#include <portability.h>
#include <config.h>
#include <clplumbing/cl_uuid.h>
@@ -33,6 +32,8 @@
#include <clplumbing/cl_misc.h>
#include <glib.h>
#include <clplumbing/Gmain_timeout.h>
+#include <clplumbing/GSource.h>
+#include <clplumbing/cl_random.h>
static void schedule_rexmit_request(struct node_info* node, seqno_t seq,
int delay);
@@ -62,7 +63,7 @@
value);
}
max_rexmit_delay =value;
- srand(cl_random());
+ srand(cl_randseed());
rand_seed_set = TRUE;
return;
@@ -217,7 +218,7 @@
if (delay == 0){
if (!rand_seed_set) {
- srand(cl_random());
+ srand(cl_randseed());
rand_seed_set = TRUE;
}
delay = ((rand()*max_rexmit_delay)+RANDROUND)/RAND_MAX;
@@ -234,6 +235,7 @@
sourceid = Gmain_timeout_add_full(G_PRIORITY_HIGH - 1, delay,
send_rexmit_request, ri, NULL);
+ G_main_setall_id(sourceid, "retransmit request", 100, 10);
if (sourceid == 0){
cl_log(LOG_ERR, "%s: scheduling a timeout event failed",
@@ -287,4 +289,3 @@
return HA_OK;
}
-
------------------------------
Message: 3
Date: Sun, 5 Feb 2006 21:57:34 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: include by alan from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : alan
Host :
Project : linux-ha
Module : include
Dir : linux-ha/include
Modified Files:
hb_api_core.h
Log Message:
Added priorities for generating random numbers in the background...
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/include/hb_api_core.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- hb_api_core.h 2 Feb 2006 20:58:56 -0000 1.16
+++ hb_api_core.h 6 Feb 2006 04:57:33 -0000 1.17
@@ -1,4 +1,4 @@
-/* $Id: hb_api_core.h,v 1.16 2006/02/02 20:58:56 alan Exp $ */
+/* $Id: hb_api_core.h,v 1.17 2006/02/06 04:57:33 alan Exp $ */
/*
* hb_api_core_h: Internal definitions and functions for the heartbeat API
*
@@ -47,7 +47,8 @@
#define PRI_CLIENTMSG (PRI_FREEMSG+1)
#define PRI_APIREGISTER (G_PRIORITY_LOW)
-#define PRI_AUDITCLIENT (PRI_APIREGISTER+1)
+#define PRI_RANDOM (PRI_APIREGISTER+1)
+#define PRI_AUDITCLIENT (PRI_RANDOM+1)
#define PRI_DUMPSTATS (G_PRIORITY_LOW+20)
void process_registerevent(IPC_Channel* chan, gpointer user_data);
------------------------------
_______________________________________________
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 27
********************************************