2420
2420
session->transaction_rollback_request= all;
2423
/***************************************************************************
2424
Handling of XA id cacheing
2425
***************************************************************************/
2427
pthread_mutex_t LOCK_xid_cache;
2430
extern "C" unsigned char *xid_get_hash_key(const unsigned char *, size_t *, bool);
2431
extern "C" void xid_free_hash(void *);
2433
unsigned char *xid_get_hash_key(const unsigned char *ptr, size_t *length,
2436
*length=((XID_STATE*)ptr)->xid.key_length();
2437
return ((XID_STATE*)ptr)->xid.key();
2440
void xid_free_hash(void *ptr)
2442
if (!((XID_STATE*)ptr)->in_session)
2443
free((unsigned char*)ptr);
2446
bool xid_cache_init()
2448
pthread_mutex_init(&LOCK_xid_cache, MY_MUTEX_INIT_FAST);
2449
return hash_init(&xid_cache, &my_charset_bin, 100, 0, 0,
2450
xid_get_hash_key, xid_free_hash, 0) != 0;
2453
void xid_cache_free()
2455
if (hash_inited(&xid_cache))
2457
hash_free(&xid_cache);
2458
pthread_mutex_destroy(&LOCK_xid_cache);
2462
XID_STATE *xid_cache_search(XID *xid)
2464
pthread_mutex_lock(&LOCK_xid_cache);
2465
XID_STATE *res=(XID_STATE *)hash_search(&xid_cache, xid->key(), xid->key_length());
2466
pthread_mutex_unlock(&LOCK_xid_cache);
2471
bool xid_cache_insert(XID *xid, enum xa_states xa_state)
2475
pthread_mutex_lock(&LOCK_xid_cache);
2476
if (hash_search(&xid_cache, xid->key(), xid->key_length()))
2478
else if (!(xs=(XID_STATE *)malloc(sizeof(*xs))))
2482
xs->xa_state=xa_state;
2485
res=my_hash_insert(&xid_cache, (unsigned char*)xs);
2487
pthread_mutex_unlock(&LOCK_xid_cache);
2491
bool xid_cache_insert(XID_STATE *xid_state)
2493
pthread_mutex_lock(&LOCK_xid_cache);
2494
assert(hash_search(&xid_cache, xid_state->xid.key(),
2495
xid_state->xid.key_length())==0);
2496
bool res=my_hash_insert(&xid_cache, (unsigned char*)xid_state);
2497
pthread_mutex_unlock(&LOCK_xid_cache);
2501
void xid_cache_delete(XID_STATE *xid_state)
2503
pthread_mutex_lock(&LOCK_xid_cache);
2504
hash_delete(&xid_cache, (unsigned char *)xid_state);
2505
pthread_mutex_unlock(&LOCK_xid_cache);
2508
2424
void Session::disconnect(uint32_t errcode, bool should_lock)