~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mf_keycaches.c

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <drizzled/global.h>
25
25
#include <mysys/mysys_err.h>
26
26
#include <mysys/my_sys.h>
27
 
#include "keycache.h"
 
27
#include <keycache.h>
28
28
#include <mysys/hash.h>
29
29
#include <mystrings/m_string.h>
30
30
 
55
55
 
56
56
typedef struct st_safe_hash_with_default
57
57
{
58
 
  pthread_rwlock_t mutex;
 
58
  rw_lock_t mutex;
59
59
  HASH hash;
60
60
  unsigned char *default_value;
61
61
  SAFE_HASH_ENTRY *root;
78
78
/* Get key and length for a SAFE_HASH_ENTRY */
79
79
 
80
80
static unsigned char *safe_hash_entry_get(SAFE_HASH_ENTRY *entry, size_t *length,
81
 
                                  bool not_used)
 
81
                                  bool not_used __attribute__((unused)))
82
82
{
83
 
  (void)not_used;
84
83
  *length=entry->length;
85
84
  return (unsigned char*) entry->key;
86
85
}
114
113
    hash->default_value= 0;
115
114
    return(1);
116
115
  }
117
 
  pthread_rwlock_init(&hash->mutex, 0);
 
116
  my_rwlock_init(&hash->mutex, 0);
118
117
  hash->default_value= default_value;
119
118
  hash->root= 0;
120
119
  return(0);
137
136
  if (hash->default_value)
138
137
  {
139
138
    hash_free(&hash->hash);
140
 
    pthread_rwlock_destroy(&hash->mutex);
 
139
    rwlock_destroy(&hash->mutex);
141
140
    hash->default_value=0;
142
141
  }
143
142
}
149
148
static unsigned char *safe_hash_search(SAFE_HASH *hash, const unsigned char *key, uint32_t length)
150
149
{
151
150
  unsigned char *result;
152
 
  pthread_rwlock_rdlock(&hash->mutex);
 
151
  rw_rdlock(&hash->mutex);
153
152
  result= hash_search(&hash->hash, key, length);
154
 
  pthread_rwlock_unlock(&hash->mutex);
 
153
  rw_unlock(&hash->mutex);
155
154
  if (!result)
156
155
    result= hash->default_value;
157
156
  else
186
185
  SAFE_HASH_ENTRY *entry;
187
186
  bool error= 0;
188
187
 
189
 
  pthread_rwlock_wrlock(&hash->mutex);
 
188
  rw_wrlock(&hash->mutex);
190
189
  entry= (SAFE_HASH_ENTRY*) hash_search(&hash->hash, key, length);
191
190
 
192
191
  if (data == hash->default_value)
211
210
  }
212
211
  else
213
212
  {
214
 
    if (!(entry= (SAFE_HASH_ENTRY *) malloc(sizeof(*entry) + length)))
 
213
    if (!(entry= (SAFE_HASH_ENTRY *) my_malloc(sizeof(*entry) + length,
 
214
                                               MYF(MY_WME))))
215
215
    {
216
216
      error= 1;
217
217
      goto end;
235
235
  }
236
236
 
237
237
end:
238
 
  pthread_rwlock_unlock(&hash->mutex);
 
238
  rw_unlock(&hash->mutex);
239
239
  return(error);
240
240
}
241
241
 
259
259
{
260
260
  SAFE_HASH_ENTRY *entry, *next;
261
261
 
262
 
  pthread_rwlock_wrlock(&hash->mutex);
 
262
  rw_wrlock(&hash->mutex);
263
263
 
264
264
  for (entry= hash->root ; entry ; entry= next)
265
265
  {
277
277
    }
278
278
  }
279
279
 
280
 
  pthread_rwlock_unlock(&hash->mutex);
 
280
  rw_unlock(&hash->mutex);
281
281
  return;
282
282
}
283
283