summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorAndrei Elkin <aelkin@mysql.com>2008-11-12 19:51:47 +0200
committerAndrei Elkin <aelkin@mysql.com>2008-11-12 19:51:47 +0200
commitca2d1846950b07115a001a37d84ce63ab2acdc6c (patch)
treeda19273bb9e832fe232c5251aa3f4d9dc29ee7f0 /mysys
parent162e550fcf986454cd1a542e98d8adc8fa81fd00 (diff)
parent1d521f6c20881997c9162bd11cadcbc77d20520b (diff)
downloadmariadb-git-ca2d1846950b07115a001a37d84ce63ab2acdc6c.tar.gz
merging 5.1 -> 5.1 rpl. 3 of 4 conflicts are resolved similarly to 6.0->6.0-rpl merging.
mysql_upgrade results changed due to the error messesge of mysqlcheck has changed.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_symlink.c17
-rw-r--r--mysys/thr_mutex.c27
2 files changed, 31 insertions, 13 deletions
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index f8c6ebf02c3..258e227bb7b 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -90,16 +90,6 @@ int my_symlink(const char *content, const char *linkname, myf MyFlags)
#endif /* HAVE_READLINK */
}
-/*
- Resolve all symbolic links in path
- 'to' may be equal to 'filename'
-
- Because purify gives a lot of UMR errors when using realpath(),
- this code is disabled when using purify.
-
- If MY_RESOLVE_LINK is given, only do realpath if the file is a link.
-*/
-
#if defined(SCO)
#define BUFF_LEN 4097
#elif defined(MAXPATHLEN)
@@ -124,10 +114,15 @@ int my_is_symlink(const char *filename __attribute__((unused)))
}
+/*
+ Resolve all symbolic links in path
+ 'to' may be equal to 'filename'
+*/
+
int my_realpath(char *to, const char *filename,
myf MyFlags __attribute__((unused)))
{
-#if defined(HAVE_REALPATH) && !defined(HAVE_purify) && !defined(HAVE_BROKEN_REALPATH)
+#if defined(HAVE_REALPATH) && !defined(HAVE_BROKEN_REALPATH)
int result=0;
char buff[BUFF_LEN];
char *ptr;
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 49003553f0b..8f9928026ba 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -438,9 +438,33 @@ int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp,
mp->spins= MY_PTHREAD_FASTMUTEX_SPINS;
else
mp->spins= 0;
+ mp->rng_state= 1;
return pthread_mutex_init(&mp->mutex, attr);
}
+/**
+ Park-Miller random number generator. A simple linear congruential
+ generator that operates in multiplicative group of integers modulo n.
+
+ x_{k+1} = (x_k g) mod n
+
+ Popular pair of parameters: n = 2^32 − 5 = 4294967291 and g = 279470273.
+ The period of the generator is about 2^31.
+ Largest value that can be returned: 2147483646 (RAND_MAX)
+
+ Reference:
+
+ S. K. Park and K. W. Miller
+ "Random number generators: good ones are hard to find"
+ Commun. ACM, October 1988, Volume 31, No 10, pages 1192-1201.
+*/
+
+static double park_rng(my_pthread_fastmutex_t *mp)
+{
+ mp->rng_state= ((my_ulonglong)mp->rng_state * 279470273U) % 4294967291U;
+ return (mp->rng_state / 2147483647.0);
+}
+
int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp)
{
int res;
@@ -458,8 +482,7 @@ int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp)
return res;
mutex_delay(maxdelay);
- maxdelay += ((double) random() / (double) RAND_MAX) *
- MY_PTHREAD_FASTMUTEX_DELAY + 1;
+ maxdelay += park_rng(mp) * MY_PTHREAD_FASTMUTEX_DELAY + 1;
}
return pthread_mutex_lock(&mp->mutex);
}