~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/xid.cc

  • Committer: Brian Aker
  • Date: 2010-05-07 06:18:08 UTC
  • mto: (1527.1.1 staging)
  • mto: This revision was merged to the branch mainline in revision 1526.
  • Revision ID: brian@gaz-20100507061808-xtbz9dgb32o783yg
Remove members to functions that are no longer used.

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