1
- /* Copyright (c) 2003, 2013 , Oracle and/or its affiliates. All rights reserved.
1
+ /* Copyright (c) 2003, 2014 , Oracle and/or its affiliates. All rights reserved.
2
2
3
3
This program is free software; you can redistribute it and/or modify
4
4
it under the terms of the GNU General Public License as published by
29
29
/*****************************************************************************
30
30
General functions to handle SAFE_HASH objects.
31
31
32
- A SAFE_HASH object is used to store the hash, the mutex and default value
32
+ A SAFE_HASH object is used to store the hash, the lock and default value
33
33
needed by the rest of the key cache code.
34
34
This is a separate struct to make it easy to later reuse the code for other
35
35
purposes
@@ -53,7 +53,7 @@ typedef struct st_safe_hash_entry
53
53
54
54
typedef struct st_safe_hash_with_default
55
55
{
56
- native_rw_lock_t mutex ;
56
+ mysql_rwlock_t lock ;
57
57
HASH hash ;
58
58
uchar * default_value ;
59
59
SAFE_HASH_ENTRY * root ;
@@ -113,7 +113,7 @@ static my_bool safe_hash_init(SAFE_HASH *hash, uint elements,
113
113
hash -> default_value = 0 ;
114
114
DBUG_RETURN (1 );
115
115
}
116
- native_rw_init ( & hash -> mutex );
116
+ mysql_rwlock_init ( key_SAFE_HASH_lock , & hash -> lock );
117
117
hash -> default_value = default_value ;
118
118
hash -> root = 0 ;
119
119
DBUG_RETURN (0 );
@@ -136,7 +136,7 @@ static void safe_hash_free(SAFE_HASH *hash)
136
136
if (hash -> default_value )
137
137
{
138
138
my_hash_free (& hash -> hash );
139
- native_rw_destroy (& hash -> mutex );
139
+ mysql_rwlock_destroy (& hash -> lock );
140
140
hash -> default_value = 0 ;
141
141
}
142
142
}
@@ -149,9 +149,9 @@ static uchar *safe_hash_search(SAFE_HASH *hash, const uchar *key, uint length)
149
149
{
150
150
uchar * result ;
151
151
DBUG_ENTER ("safe_hash_search" );
152
- native_rw_rdlock (& hash -> mutex );
152
+ mysql_rwlock_rdlock (& hash -> lock );
153
153
result = my_hash_search (& hash -> hash , key , length );
154
- native_rw_unlock (& hash -> mutex );
154
+ mysql_rwlock_unlock (& hash -> lock );
155
155
if (!result )
156
156
result = hash -> default_value ;
157
157
else
@@ -189,7 +189,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
189
189
DBUG_ENTER ("safe_hash_set" );
190
190
DBUG_PRINT ("enter" ,("key: %.*s data: 0x%lx" , length , key , (long ) data ));
191
191
192
- native_rw_wrlock (& hash -> mutex );
192
+ mysql_rwlock_wrlock (& hash -> lock );
193
193
entry = (SAFE_HASH_ENTRY * ) my_hash_search (& hash -> hash , key , length );
194
194
195
195
if (data == hash -> default_value )
@@ -240,7 +240,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
240
240
}
241
241
242
242
end :
243
- native_rw_unlock (& hash -> mutex );
243
+ mysql_rwlock_unlock (& hash -> lock );
244
244
DBUG_RETURN (error );
245
245
}
246
246
@@ -265,7 +265,7 @@ static void safe_hash_change(SAFE_HASH *hash, uchar *old_data, uchar *new_data)
265
265
SAFE_HASH_ENTRY * entry , * next ;
266
266
DBUG_ENTER ("safe_hash_set" );
267
267
268
- native_rw_wrlock (& hash -> mutex );
268
+ mysql_rwlock_wrlock (& hash -> lock );
269
269
270
270
for (entry = hash -> root ; entry ; entry = next )
271
271
{
@@ -283,7 +283,7 @@ static void safe_hash_change(SAFE_HASH *hash, uchar *old_data, uchar *new_data)
283
283
}
284
284
}
285
285
286
- native_rw_unlock (& hash -> mutex );
286
+ mysql_rwlock_unlock (& hash -> lock );
287
287
DBUG_VOID_RETURN ;
288
288
}
289
289
0 commit comments