Author: cotto
Date: Fri Dec 19 18:11:39 2008
New Revision: 34127
Modified:
trunk/src/hash.c
trunk/src/string.c
Log:
[hash] randomize an interp's hash seed, or inhert the parent's seed if
applicable
Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c (original)
+++ trunk/src/hash.c Fri Dec 19 18:11:39 2008
@@ -144,7 +144,7 @@
static size_t
key_hash_STRING(PARROT_INTERP, ARGMOD(STRING *s), size_t seed)
{
- if (PObj_is_shared_TEST(s) || s->hashval == 0) {
+ if (s->hashval == 0) {
return string_hash(interp, s);
}
Modified: trunk/src/string.c
==============================================================================
--- trunk/src/string.c (original)
+++ trunk/src/string.c Fri Dec 19 18:11:39 2008
@@ -283,12 +283,14 @@
const size_t n_parrot_cstrings =
sizeof (parrot_cstrings) / sizeof (parrot_cstrings[0]);
- /* TODO: hash_seed should be randomized on a per-interp basis. Before this
- * can happen, shared STRINGs need to always be marked as such.
- * See RT #59810 and #59472
- */
- interp->hash_seed = 3793;
- /*interp->hash_seed = Parrot_uint_rand(0);*/
+ if (interp->parent_interpreter) {
+ interp->hash_seed = interp->parent_interpreter->hash_seed;
+ }
+ else {
+ /* TT #64 - use an entropy source once available */
+ Parrot_srand(Parrot_intval_time());
+ interp->hash_seed = Parrot_uint_rand(0);
+ }
/* Set up the cstring cache, then load the basic encodings and charsets */
if (!interp->parent_interpreter) {