~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/locking/global.cc

Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
        lock request will set its lock type properly.
163
163
*/
164
164
 
165
 
static void reset_lock_data_and_free(DrizzleLock **mysql_lock)
 
165
static void reset_lock_data_and_free(DrizzleLock*& lock)
166
166
{
167
 
  DrizzleLock *sql_lock= *mysql_lock;
168
 
  sql_lock->reset();
169
 
  delete sql_lock;
170
 
  *mysql_lock= 0;
 
167
  lock->reset();
 
168
  delete lock;
 
169
  lock= NULL;
171
170
}
172
171
 
173
172
DrizzleLock *Session::lockTables(Table **tables, uint32_t count, uint32_t flags)
190
189
      if (wait_if_global_read_lock(1, 1))
191
190
      {
192
191
        /* Clear the lock type of all lock data to avoid reusage. */
193
 
        reset_lock_data_and_free(&sql_lock);
 
192
        reset_lock_data_and_free(sql_lock);
194
193
        break;
195
194
      }
196
195
 
197
196
      if (open_tables.version != g_refresh_version)
198
197
      {
199
198
        /* Clear the lock type of all lock data to avoid reusage. */
200
 
        reset_lock_data_and_free(&sql_lock);
 
199
        reset_lock_data_and_free(sql_lock);
201
200
        break;
202
201
      }
203
202
    }
239
238
    if (sql_lock->sizeTable() && lock_external(sql_lock->getTable(), sql_lock->sizeTable()))
240
239
    {
241
240
      /* Clear the lock type of all lock data to avoid reusage. */
242
 
      reset_lock_data_and_free(&sql_lock);
 
241
      reset_lock_data_and_free(sql_lock);
243
242
      break;
244
243
    }
245
244
    set_proc_info("Table lock");
259
258
    {
260
259
      if (sql_lock->sizeTable())
261
260
        unlock_external(sql_lock->getTable(), sql_lock->sizeTable());
262
 
      reset_lock_data_and_free(&sql_lock);
 
261
      reset_lock_data_and_free(sql_lock);
263
262
      my_error(rc, MYF(0));
264
263
    }
265
264
  } while(0);
558
557
        my_error(ER_OPEN_AS_READONLY, MYF(0), table->getAlias());
559
558
        /* Clear the lock type of the lock data that are stored already. */
560
559
        sql_lock->setLock(locks - sql_lock->getLocks());
561
 
        reset_lock_data_and_free(&sql_lock);
 
560
        reset_lock_data_and_free(sql_lock);
562
561
        return NULL;
563
562
      }
564
563
    }