summaryrefslogtreecommitdiffstats
path: root/src/H5SL.c
diff options
context:
space:
mode:
authorLeon Arber <larber@ncsa.uiuc.edu>2006-03-07 04:23:24 (GMT)
committerLeon Arber <larber@ncsa.uiuc.edu>2006-03-07 04:23:24 (GMT)
commit840bcbe9ef762ae755df3f97fdac15d84df8909f (patch)
tree109540f2e45343bb529661b15962ece095ca7561 /src/H5SL.c
parent4efe32d5426f92083925d18183bc8669b58967b0 (diff)
downloadhdf5-840bcbe9ef762ae755df3f97fdac15d84df8909f.zip
hdf5-840bcbe9ef762ae755df3f97fdac15d84df8909f.tar.gz
hdf5-840bcbe9ef762ae755df3f97fdac15d84df8909f.tar.bz2
[svn-r12019] Purpose:
Bug fix/Feature Description: Modify the library to use rand_r, when available, instead of srand. If rand_r is not available, it will try to use srandom/random, and then finally fall back to srand/rand. Solution: A couple places in the library use the srand() function to seed the random number generator. This can cause problems on certain platforms and could theoretically cause problems for users who expect a certain sequence of random numbers following their own call to srand(). Most platforms have an implementation of rand_r, which is identical to rand, except that it allows for explicit storage of the seed value. The configure script will now check for the existence of rand_r to facilitate its use in the library. Two new functions are added, to replace the macros HDsrand/HDrand. These functions are HDrand and HDsrand. HDrand will call rand_r, if available, or random(), if available, and fall back to rand() if neither of those is available. HDsrand will store the seed value locally, if rand_r is available. Otherwise, it will call srandom if available, and fall back to srand otherwise. Platforms tested: heping, mir. Really need to test on Red Storm, since that platform motivated this fix, but the machine is currently not available. Misc. update:
Diffstat (limited to 'src/H5SL.c')
-rw-r--r--src/H5SL.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/H5SL.c b/src/H5SL.c
index 4f1305c..4202481 100644
--- a/src/H5SL.c
+++ b/src/H5SL.c
@@ -203,7 +203,7 @@ H5FL_BARR_DEFINE_STATIC(H5SL_node_t,H5SL_node_ptr_t,H5SL_LEVEL_MAX);
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static herr_t
+ static herr_t
H5SL_init_interface(void)
{
time_t curr_time; /* Current time, for seeding random number generator */
@@ -214,12 +214,14 @@ H5SL_init_interface(void)
* This causes Lustre on Redstorm to hang with following errors. (Lustre
* has fix it, but not deployed at RedStorm yet.
* (client.c:568:ptlrpc_check_status()) @@@ type == PTL_RPC_MSG_ERR, err == -114 req@0x57a9660 x1/t0 o38->mds_l2@MDS_PEER_UUID:12 lens 240/272 ref 1 fl Rpc:R/100000/0 rc 0/-114
- */
-#ifndef RED_STORM
- /* Create randomized set of numbers */
+ *
+ * 3/6/06. LA:
+ * Shouldn't need patch anymore because HDsrand will use rand_r on Red Storm instead of srand.
+ */
+
+/* Create randomized set of numbers */
curr_time=HDtime(NULL);
HDsrand((unsigned)curr_time);
-#endif
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5SL_init_interface() */