~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/db.cc

  • Committer: Brian Aker
  • Date: 2010-11-23 07:02:38 UTC
  • mfrom: (1945.2.1 quick)
  • Revision ID: brian@tangent.org-20101123070238-1f31pgg7gvmytpr3
Refactor basic lock bits (ie, encapsulate!)

Show diffs side-by-side

added added

removed removed

Lines of Context:
271
271
    }
272
272
    else
273
273
    {
274
 
      LOCK_open.lock(); /* After deleting database, remove all cache entries related to schema */
 
274
      /* After deleting database, remove all cache entries related to schema */
275
275
      table::Cache::singleton().removeSchema(schema_identifier);
276
 
      LOCK_open.unlock();
277
276
 
278
277
 
279
278
      error= -1;
358
357
  int error= 0;
359
358
  bool foreign_key_error= false;
360
359
 
361
 
  LOCK_open.lock(); /* Part 2 of rm a table */
 
360
  table::Cache::singleton().mutex().lock(); /* Part 2 of rm a table */
362
361
 
363
362
  if (session->lock_table_names_exclusively(tables))
364
363
  {
365
 
    LOCK_open.unlock();
 
364
    table::Cache::singleton().mutex().unlock();
366
365
    return 1;
367
366
  }
368
367
 
385
384
    case -1:
386
385
      error= 1;
387
386
      tables->unlock_table_names();
388
 
      LOCK_open.unlock();
 
387
      table::Cache::singleton().mutex().unlock();
389
388
      session->no_warnings_for_error= 0;
390
389
 
391
390
      return(error);
413
412
      {
414
413
        error= -1;
415
414
        tables->unlock_table_names();
416
 
        LOCK_open.unlock();
 
415
        table::Cache::singleton().mutex().unlock();
417
416
        session->no_warnings_for_error= 0;
418
417
 
419
418
        return(error);
458
457
    }
459
458
  }
460
459
  /*
461
 
    It's safe to unlock LOCK_open: we have an exclusive lock
 
460
    It's safe to unlock table::Cache::singleton().mutex(): we have an exclusive lock
462
461
    on the table name.
463
462
  */
464
 
  LOCK_open.unlock();
 
463
  table::Cache::singleton().mutex().unlock();
465
464
  error= 0;
466
465
  if (wrong_tables.length())
467
466
  {
475
474
    error= 1;
476
475
  }
477
476
 
478
 
  LOCK_open.lock(); /* final bit in rm table lock */
 
477
  table::Cache::singleton().mutex().lock(); /* final bit in rm table lock */
479
478
  tables->unlock_table_names();
480
 
  LOCK_open.unlock();
 
479
  table::Cache::singleton().mutex().unlock();
481
480
  session->no_warnings_for_error= 0;
482
481
 
483
482
  return(error);