diff options
author | Monty <monty@mariadb.org> | 2017-01-29 23:44:24 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-02-28 16:10:46 +0100 |
commit | c5e25c8b40e8c75d690dbc0e441abbefdd3cdcf4 (patch) | |
tree | 498143cfbf5a6c80bd15a0f39a3d07f62e0aaa43 /mysys/hash.c | |
parent | e65f667bb60244610512efd7491fc77eccceb9db (diff) | |
download | mariadb-git-c5e25c8b40e8c75d690dbc0e441abbefdd3cdcf4.tar.gz |
Added a separate lock for start/stop/reset slave.
This solves some possible dead locks when one calls stop slave while slave
is starting.
Diffstat (limited to 'mysys/hash.c')
-rw-r--r-- | mysys/hash.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index 344b698a433..c2f3555396e 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -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; } @@ -519,6 +524,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 |