~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/xid.cc

Remove dead memset call.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <drizzled/my_hash.h>
24
24
#include <drizzled/xid.h>
25
 
#include "drizzled/internal/my_pthread.h"
26
25
#include "drizzled/charset.h"
27
26
#include "drizzled/global_charset_info.h"
28
27
#include "drizzled/charset_info.h"
29
28
 
 
29
#include <boost/thread/mutex.hpp>
 
30
 
30
31
namespace drizzled
31
32
{
32
33
 
115
116
/***************************************************************************
116
117
  Handling of XA id cacheing
117
118
***************************************************************************/
118
 
pthread_mutex_t LOCK_xid_cache;
 
119
boost::mutex LOCK_xid_cache;
119
120
HASH xid_cache;
120
121
 
121
122
unsigned char *xid_get_hash_key(const unsigned char *, size_t *, bool);
137
138
 
138
139
bool xid_cache_init()
139
140
{
140
 
  pthread_mutex_init(&LOCK_xid_cache, MY_MUTEX_INIT_FAST);
141
141
  return hash_init(&xid_cache, &my_charset_bin, 100, 0, 0,
142
142
                   xid_get_hash_key, xid_free_hash, 0) != 0;
143
143
}
147
147
  if (hash_inited(&xid_cache))
148
148
  {
149
149
    hash_free(&xid_cache);
150
 
    pthread_mutex_destroy(&LOCK_xid_cache);
151
150
  }
152
151
}
153
152
 
154
153
XID_STATE *xid_cache_search(XID *xid)
155
154
{
156
 
  pthread_mutex_lock(&LOCK_xid_cache);
 
155
  LOCK_xid_cache.lock();
157
156
  XID_STATE *res=(XID_STATE *)hash_search(&xid_cache, xid->key(), xid->key_length());
158
 
  pthread_mutex_unlock(&LOCK_xid_cache);
 
157
  LOCK_xid_cache.unlock();
159
158
  return res;
160
159
}
161
160
 
163
162
{
164
163
  XID_STATE *xs;
165
164
  bool res;
166
 
  pthread_mutex_lock(&LOCK_xid_cache);
 
165
  LOCK_xid_cache.lock();
167
166
  if (hash_search(&xid_cache, xid->key(), xid->key_length()))
 
167
  {
168
168
    res= false;
 
169
  }
169
170
  else if ((xs = new XID_STATE) == NULL)
 
171
  {
170
172
    res= true;
 
173
  }
171
174
  else
172
175
  {
173
176
    xs->xa_state=xa_state;
175
178
    xs->in_session=0;
176
179
    res= my_hash_insert(&xid_cache, (unsigned char*)xs);
177
180
  }
178
 
  pthread_mutex_unlock(&LOCK_xid_cache);
 
181
  LOCK_xid_cache.unlock();
179
182
  return res;
180
183
}
181
184
 
182
185
bool xid_cache_insert(XID_STATE *xid_state)
183
186
{
184
 
  pthread_mutex_lock(&LOCK_xid_cache);
 
187
  LOCK_xid_cache.lock();
185
188
  bool res=my_hash_insert(&xid_cache, (unsigned char*)xid_state);
186
 
  pthread_mutex_unlock(&LOCK_xid_cache);
 
189
  LOCK_xid_cache.unlock();
187
190
  return res;
188
191
}
189
192
 
190
193
void xid_cache_delete(XID_STATE *xid_state)
191
194
{
192
 
  pthread_mutex_lock(&LOCK_xid_cache);
 
195
  LOCK_xid_cache.lock();
193
196
  hash_delete(&xid_cache, (unsigned char *)xid_state);
194
 
  pthread_mutex_unlock(&LOCK_xid_cache);
 
197
  LOCK_xid_cache.unlock();
195
198
}
196
199
 
197
200
} /* namespace drizzled */