#include "mysys_priv.h"#include <keycache.h>#include <hash.h>#include <m_string.h>Include dependency graph for mf_keycaches.c:

Go to the source code of this file.
| typedef struct st_safe_hash_with_default SAFE_HASH |
| typedef struct st_safe_hash_entry SAFE_HASH_ENTRY |
Definition at line 360 of file mf_keycaches.c.
References key_cache_hash, and safe_hash_change().
Referenced by mi_change_key_cache().
00362 { 00363 safe_hash_change(&key_cache_hash, (byte*) old_data, (byte*) new_data); 00364 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 329 of file mf_keycaches.c.
References dflt_key_cache, st_safe_hash_with_default::hash, key_cache_hash, st_hash::records, and safe_hash_search().
Referenced by mi_open().
00330 { 00331 if (!key_cache_hash.hash.records) 00332 return dflt_key_cache; 00333 return (KEY_CACHE*) safe_hash_search(&key_cache_hash, key, length); 00334 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 353 of file mf_keycaches.c.
References key_cache_hash, and safe_hash_set().
Referenced by mi_assign_to_key_cache().
00355 { 00356 return safe_hash_set(&key_cache_hash, key, length, (byte*) key_cache); 00357 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void multi_keycache_free | ( | void | ) |
Definition at line 307 of file mf_keycaches.c.
References key_cache_hash, and safe_hash_free().
Referenced by clean_up().
00308 { 00309 safe_hash_free(&key_cache_hash); 00310 }
Here is the call graph for this function:

Here is the caller graph for this function:

| my_bool multi_keycache_init | ( | void | ) |
Definition at line 301 of file mf_keycaches.c.
References dflt_key_cache, key_cache_hash, and safe_hash_init().
Referenced by mysql_init_variables().
00302 { 00303 return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_key_cache); 00304 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 265 of file mf_keycaches.c.
References DBUG_ENTER, DBUG_VOID_RETURN, hash(), hash_delete(), rw_unlock, and rw_wrlock.
Referenced by multi_key_cache_change().
00266 { 00267 SAFE_HASH_ENTRY *entry, *next; 00268 DBUG_ENTER("safe_hash_set"); 00269 00270 rw_wrlock(&hash->mutex); 00271 00272 for (entry= hash->root ; entry ; entry= next) 00273 { 00274 next= entry->next; 00275 if (entry->data == old_data) 00276 { 00277 if (new_data == hash->default_value) 00278 { 00279 if ((*entry->prev= entry->next)) 00280 entry->next->prev= entry->prev; 00281 hash_delete(&hash->hash, (byte*) entry); 00282 } 00283 else 00284 entry->data= new_data; 00285 } 00286 } 00287 00288 rw_unlock(&hash->mutex); 00289 DBUG_VOID_RETURN; 00290 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void safe_hash_entry_free | ( | SAFE_HASH_ENTRY * | entry | ) | [static] |
Definition at line 72 of file mf_keycaches.c.
References DBUG_ENTER, DBUG_VOID_RETURN, my_free, and MYF.
Referenced by safe_hash_init().
00073 { 00074 DBUG_ENTER("free_assign_entry"); 00075 my_free((gptr) entry, MYF(0)); 00076 DBUG_VOID_RETURN; 00077 }
Here is the caller graph for this function:

| static byte* safe_hash_entry_get | ( | SAFE_HASH_ENTRY * | entry, | |
| uint * | length, | |||
| my_bool not_used | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 82 of file mf_keycaches.c.
Referenced by safe_hash_init().
Here is the caller graph for this function:

| static void safe_hash_free | ( | SAFE_HASH * | hash | ) | [static] |
Definition at line 133 of file mf_keycaches.c.
References hash(), hash_free(), and rwlock_destroy.
Referenced by multi_keycache_free().
00134 { 00135 /* 00136 Test if safe_hash_init succeeded. This will also guard us against multiple 00137 free calls. 00138 */ 00139 if (hash->default_value) 00140 { 00141 hash_free(&hash->hash); 00142 rwlock_destroy(&hash->mutex); 00143 hash->default_value=0; 00144 } 00145 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 108 of file mf_keycaches.c.
References DBUG_ENTER, DBUG_RETURN, hash(), hash_init, my_charset_bin, my_rwlock_init, safe_hash_entry_free(), and safe_hash_entry_get().
Referenced by multi_keycache_init().
00110 { 00111 DBUG_ENTER("safe_hash"); 00112 if (hash_init(&hash->hash, &my_charset_bin, elements, 00113 0, 0, (hash_get_key) safe_hash_entry_get, 00114 (void (*)(void*)) safe_hash_entry_free, 0)) 00115 { 00116 hash->default_value= 0; 00117 DBUG_RETURN(1); 00118 } 00119 my_rwlock_init(&hash->mutex, 0); 00120 hash->default_value= default_value; 00121 hash->root= 0; 00122 DBUG_RETURN(0); 00123 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 151 of file mf_keycaches.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, hash(), hash_search(), rw_rdlock, and rw_unlock.
Referenced by multi_key_cache_search().
00152 { 00153 byte *result; 00154 DBUG_ENTER("safe_hash_search"); 00155 rw_rdlock(&hash->mutex); 00156 result= hash_search(&hash->hash, key, length); 00157 rw_unlock(&hash->mutex); 00158 if (!result) 00159 result= hash->default_value; 00160 else 00161 result= ((SAFE_HASH_ENTRY*) result)->data; 00162 DBUG_PRINT("exit",("data: 0x%lx", result)); 00163 DBUG_RETURN(result); 00164 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static my_bool safe_hash_set | ( | SAFE_HASH * | hash, | |
| const byte * | key, | |||
| uint | length, | |||
| byte * | data | |||
| ) | [static] |
Definition at line 187 of file mf_keycaches.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, error, hash(), hash_delete(), hash_search(), memcpy, my_free, my_hash_insert(), my_malloc(), MY_WME, MYF, rw_unlock, and rw_wrlock.
Referenced by multi_key_cache_set().
00189 { 00190 SAFE_HASH_ENTRY *entry; 00191 my_bool error= 0; 00192 DBUG_ENTER("safe_hash_set"); 00193 DBUG_PRINT("enter",("key: %.*s data: 0x%lx", length, key, data)); 00194 00195 rw_wrlock(&hash->mutex); 00196 entry= (SAFE_HASH_ENTRY*) hash_search(&hash->hash, key, length); 00197 00198 if (data == hash->default_value) 00199 { 00200 /* 00201 The key is to be associated with the default entry. In this case 00202 we can just delete the entry (if it existed) from the hash as a 00203 search will return the default entry 00204 */ 00205 if (!entry) /* nothing to do */ 00206 goto end; 00207 /* unlink entry from list */ 00208 if ((*entry->prev= entry->next)) 00209 entry->next->prev= entry->prev; 00210 hash_delete(&hash->hash, (byte*) entry); 00211 goto end; 00212 } 00213 if (entry) 00214 { 00215 /* Entry existed; Just change the pointer to point at the new data */ 00216 entry->data= data; 00217 } 00218 else 00219 { 00220 if (!(entry= (SAFE_HASH_ENTRY *) my_malloc(sizeof(*entry) + length, 00221 MYF(MY_WME)))) 00222 { 00223 error= 1; 00224 goto end; 00225 } 00226 entry->key= (byte*) (entry +1); 00227 memcpy((char*) entry->key, (char*) key, length); 00228 entry->length= length; 00229 entry->data= data; 00230 /* Link entry to list */ 00231 if ((entry->next= hash->root)) 00232 entry->next->prev= &entry->next; 00233 entry->prev= &hash->root; 00234 hash->root= entry; 00235 if (my_hash_insert(&hash->hash, (byte*) entry)) 00236 { 00237 /* This can only happen if hash got out of memory */ 00238 my_free((char*) entry, MYF(0)); 00239 error= 1; 00240 goto end; 00241 } 00242 } 00243 00244 end: 00245 rw_unlock(&hash->mutex); 00246 DBUG_RETURN(error); 00247 }
Here is the call graph for this function:

Here is the caller graph for this function:

SAFE_HASH key_cache_hash [static] |
Definition at line 298 of file mf_keycaches.c.
Referenced by multi_key_cache_change(), multi_key_cache_search(), multi_key_cache_set(), multi_keycache_free(), and multi_keycache_init().
1.4.7

