Commit 79d36c8e authored by unknown's avatar unknown

storage/maria/trnman.c

    fix for architectures not supported by my_atomic.h
    we cannot iterate the array over and over without releasing a lock


storage/maria/trnman.c:
  fix for architectures not supported by my_atomic.h
  we cannot iterate the array over and over without releasing a lock
parent 111a6fd5
...@@ -209,16 +209,21 @@ static TrID new_trid() ...@@ -209,16 +209,21 @@ static TrID new_trid()
static void set_short_trid(TRN *trn) static void set_short_trid(TRN *trn)
{ {
int i= (global_trid_generator + (intptr)trn) * 312089 % SHORT_TRID_MAX + 1; int i= (global_trid_generator + (intptr)trn) * 312089 % SHORT_TRID_MAX + 1;
for ( ; !trn->short_id ; i= 1)
{
my_atomic_rwlock_wrlock(&LOCK_short_trid_to_trn); my_atomic_rwlock_wrlock(&LOCK_short_trid_to_trn);
for ( ; ; i= i % SHORT_TRID_MAX + 1) /* the range is [1..SHORT_TRID_MAX] */ for ( ; i <= SHORT_TRID_MAX; i++) /* the range is [1..SHORT_TRID_MAX] */
{ {
void *tmp= NULL; void *tmp= NULL;
if (short_trid_to_active_trn[i] == NULL && if (short_trid_to_active_trn[i] == NULL &&
my_atomic_casptr((void **)&short_trid_to_active_trn[i], &tmp, trn)) my_atomic_casptr((void **)&short_trid_to_active_trn[i], &tmp, trn))
{
trn->short_id= i;
break; break;
} }
}
my_atomic_rwlock_wrunlock(&LOCK_short_trid_to_trn); my_atomic_rwlock_wrunlock(&LOCK_short_trid_to_trn);
trn->short_id= i; }
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment