summaryrefslogtreecommitdiff
path: root/mysys/hash.c
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-03-30 12:48:42 +0200
committerSergei Golubchik <serg@mariadb.org>2017-03-30 12:48:42 +0200
commitda4d71d10d23c1ac2d10b72baee14991ccb7a146 (patch)
tree7cdf3a8c8e72ca7c1c8105427c04123f025bd870 /mysys/hash.c
parent9ec85009985d644ce7ae797bc3572d0ad0f69bb0 (diff)
parenta00517ac9707ffd51c092f5af5d198c5ee789bb4 (diff)
downloadmariadb-git-da4d71d10d23c1ac2d10b72baee14991ccb7a146.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'mysys/hash.c')
-rw-r--r--mysys/hash.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/mysys/hash.c b/mysys/hash.c
index 1d6b3d5daaa..ad01afba29e 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -62,7 +62,7 @@ my_hash_value_type my_hash_sort(CHARSET_INFO *cs, const uchar *key,
@param[in,out] hash The hash that is initialized
@param[in[ growth_size size incrememnt for the underlying dynarray
- @param[in] charset The charater set information
+ @param[in] charset The character set information
@param[in] size The hash size
@param[in] key_offest The key offset for the hash
@param[in] key_length The length of the key used in
@@ -115,14 +115,19 @@ my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
static inline void my_hash_free_elements(HASH *hash)
{
+ uint records= hash->records;
+ /*
+ Set records to 0 early to guard against anyone looking at the structure
+ during the free process
+ */
+ hash->records= 0;
if (hash->free)
{
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
- HASH_LINK *end= data + hash->records;
+ HASH_LINK *end= data + records;
while (data < end)
(*hash->free)((data++)->data);
}
- hash->records=0;
}
@@ -531,6 +536,9 @@ my_bool my_hash_insert(HASH *info, const uchar *record)
The record with the same record ptr is removed.
If there is a free-function it's called if record was found.
+ hash->free() is guarantee to be called only after the row has been
+ deleted from the hash and the hash can be reused by other threads.
+
@return
@retval 0 ok
@retval 1 Record not found
@@ -622,7 +630,7 @@ exit:
/**
Update keys when record has changed.
- This is much more efficent than using a delete & insert.
+ This is much more efficient than using a delete & insert.
*/
my_bool my_hash_update(HASH *hash, uchar *record, uchar *old_key,