~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/locking/global.cc

  • Committer: Mark Atwood
  • Date: 2011-06-28 16:14:02 UTC
  • mfrom: (2318.6.95 refactor18)
  • Revision ID: me@mark.atwood.name-20110628161402-epi386unt3n43lm6
mergeĀ lp:~olafvdspek/drizzle/refactor18

Show diffs side-by-side

added added

removed removed

Lines of Context:
455
455
 
456
456
bool Session::abortLockForThread(Table *table)
457
457
{
458
 
  DrizzleLock *locked;
459
 
  Table *write_lock_used;
460
458
  bool result= false;
461
 
 
462
 
  if ((locked= get_lock_data(&table, 1, false,
463
 
                             &write_lock_used)))
 
459
  Table* write_lock_used;
 
460
  if (DrizzleLock* locked= get_lock_data(&table, 1, false, &write_lock_used))
464
461
  {
465
462
    for (uint32_t i= 0; i < locked->sizeLock(); i++)
466
463
    {
476
473
 
477
474
int Session::unlock_external(Table **table, uint32_t count)
478
475
{
479
 
  int error,error_code;
 
476
  int error;
480
477
 
481
 
  error_code=0;
 
478
  int error_code=0;
482
479
  do
483
480
  {
484
481
    if ((*table)->current_lock != F_UNLCK)
542
539
  for (uint32_t i= 0; i < count ; i++)
543
540
  {
544
541
    Table *table;
545
 
    enum thr_lock_type lock_type;
 
542
    thr_lock_type lock_type;
546
543
 
547
544
    if (table_ptr[i]->getEngine()->check_flag(HTON_BIT_SKIP_STORE_LOCK))
548
545
      continue;
563
560
      }
564
561
    }
565
562
    locks_start= locks;
566
 
    locks= table->cursor->store_lock(this, locks, should_lock == false ? TL_IGNORE : lock_type);
 
563
    locks= table->cursor->store_lock(this, locks, should_lock ? lock_type : TL_IGNORE);
567
564
    if (should_lock)
568
565
    {
569
566
      table->lock_position=   (uint32_t) (to - table_buf);
659
656
 
660
657
static bool locked_named_table(TableList *table_list)
661
658
{
662
 
  for (; table_list ; table_list=table_list->next_local)
 
659
  for (; table_list; table_list=table_list->next_local)
663
660
  {
664
661
    Table *table= table_list->table;
665
662
    if (table)
666
663
    {
667
664
      Table *save_next= table->getNext();
668
 
      bool result;
669
665
      table->setNext(NULL);
670
 
      result= table::Cache::areTablesUsed(table_list->table, 0);
 
666
      bool result= table::Cache::areTablesUsed(table_list->table, 0);
671
667
      table->setNext(save_next);
672
668
      if (result)
673
669
        return 1;
689
685
  {
690
686
    if (getKilled())
691
687
    {
692
 
      result=1;
 
688
      result= true;
693
689
      break;
694
690
    }
695
691
    wait_for_condition(table::Cache::mutex(), COND_refresh);
716
712
bool Session::lock_table_names(TableList *table_list)
717
713
{
718
714
  bool got_all_locks= true;
719
 
  TableList *lock_table;
720
 
 
721
 
  for (lock_table= table_list; lock_table; lock_table= lock_table->next_local)
 
715
  for (TableList* lock_table= table_list; lock_table; lock_table= lock_table->next_local)
722
716
  {
723
 
    int got_lock;
724
 
    if ((got_lock= lock_table_name(lock_table)) < 0)
 
717
    int got_lock= lock_table_name(lock_table);
 
718
    if (got_lock < 0)
725
719
    {
726
720
      table_list->unlock_table_names(table_list);
727
721
      return true; // Fatal error
728
722
    }
729
 
 
730
723
    if (got_lock)
731
724
      got_all_locks= false;                             // Someone is using table
732
725
  }
735
728
  if (not got_all_locks && wait_for_locked_table_names(table_list))
736
729
  {
737
730
    table_list->unlock_table_names(table_list);
738
 
 
739
731
    return true;
740
732
  }
741
 
 
742
733
  return false;
743
734
}
744
735
 
802
793
 
803
794
void TableList::unlock_table_names(TableList *last_table)
804
795
{
805
 
  for (TableList *table_iter= this;
806
 
       table_iter != last_table;
807
 
       table_iter= table_iter->next_local)
 
796
  for (TableList *table_iter= this; table_iter != last_table; table_iter= table_iter->next_local)
808
797
  {
809
798
    table_iter->unlock_table_name();
810
799
  }
811
 
 
812
800
  locking::broadcast_refresh();
813
801
}
814
802
 
816
804
static void print_lock_error(int error, const char *table)
817
805
{
818
806
  drizzled::error_t textno;
819
 
 
820
 
  switch (error) {
 
807
  switch (error) 
 
808
  {
821
809
  case HA_ERR_LOCK_WAIT_TIMEOUT:
822
810
    textno=ER_LOCK_WAIT_TIMEOUT;
823
811
    break;
1051
1039
 
1052
1040
void Session::startWaitingGlobalReadLock()
1053
1041
{
1054
 
  bool tmp;
1055
1042
  if (unlikely(isGlobalReadLock()))
1056
1043
    return;
1057
1044
 
1058
1045
  LOCK_global_read_lock.lock();
1059
 
  tmp= (!--protect_against_global_read_lock &&
1060
 
        (waiting_for_read_lock || global_read_lock_blocks_commit));
 
1046
  bool tmp= (!--protect_against_global_read_lock && (waiting_for_read_lock || global_read_lock_blocks_commit));
1061
1047
  LOCK_global_read_lock.unlock();
1062
1048
 
1063
1049
  if (tmp)
1120
1106
    handling, it is not necessary to also signal COND_refresh.
1121
1107
*/
1122
1108
 
1123
 
namespace locking {
1124
 
 
1125
 
void broadcast_refresh(void)
 
1109
void locking::broadcast_refresh()
1126
1110
{
1127
1111
  COND_refresh.notify_all();
1128
1112
  COND_global_read_lock.notify_all();
1129
1113
}
1130
1114
 
1131
 
}
1132
 
 
1133
 
 
1134
 
/**
1135
 
  @} (end of group Locking)
1136
 
*/
1137
 
 
1138
1115
} /* namespace drizzled */