~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/thr_lock.cc

  • Committer: Brian Aker
  • Date: 2009-05-13 02:07:22 UTC
  • mfrom: (1008.1.5 merge)
  • Revision ID: brian@gaz-20090513020722-9nqehweityhn6ab0
Merge in refactoring around lock system

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
TL_READ                 # Low priority read
28
28
TL_READ_WITH_SHARED_LOCKS
29
 
TL_READ_HIGH_PRIORITY   # High priority read
30
29
TL_READ_NO_INSERT       # Read without concurrent inserts
31
30
TL_WRITE_ALLOW_WRITE    # Write lock that allows other writers
32
31
TL_WRITE_ALLOW_READ     # Write lock, but allow reading
33
32
TL_WRITE_CONCURRENT_INSERT
34
33
                        # Insert that can be mixed when selects
35
 
TL_WRITE_LOW_PRIORITY   # Low priority write
36
34
TL_WRITE                # High priority write
37
35
TL_WRITE_ONLY           # High priority write
38
36
                        # Abort all new lock request with an error
180
178
  return 0;
181
179
}
182
180
 
183
 
static inline bool have_specific_lock(THR_LOCK_DATA *data,
184
 
                                         enum thr_lock_type type)
185
 
{
186
 
  for ( ; data ; data=data->next)
187
 
  {
188
 
    if (data->type == type)
189
 
      return 1;
190
 
  }
191
 
  return 0;
192
 
}
193
 
 
194
 
 
195
181
static void wake_up_waiters(THR_LOCK *lock);
196
182
 
197
183
 
311
297
 
312
298
      if (thr_lock_owner_equal(data->owner, lock->write.data->owner) ||
313
299
          (lock->write.data->type <= TL_WRITE_CONCURRENT_INSERT &&
314
 
           (((int) lock_type <= (int) TL_READ_HIGH_PRIORITY) ||
 
300
           (((int) lock_type <= (int) TL_READ_WITH_SHARED_LOCKS) ||
315
301
            (lock->write.data->type != TL_WRITE_CONCURRENT_INSERT &&
316
302
             lock->write.data->type != TL_WRITE_ALLOW_READ))))
317
303
      {                                         /* Already got a write lock */
334
320
      }
335
321
    }
336
322
    else if (!lock->write_wait.data ||
337
 
             lock->write_wait.data->type <= TL_WRITE_LOW_PRIORITY ||
338
 
             lock_type == TL_READ_HIGH_PRIORITY ||
 
323
             lock->write_wait.data->type <= TL_WRITE_DEFAULT ||
339
324
             have_old_read_lock(lock->read.data, data->owner))
340
325
    {                                           /* No important write-locks */
341
326
      (*lock->read.last)=data;                  /* Add to running FIFO */
547
532
    {
548
533
      /* Release write-locks with TL_WRITE or TL_WRITE_ONLY priority first */
549
534
      if (data &&
550
 
          (data->type != TL_WRITE_LOW_PRIORITY || !lock->read_wait.data ||
551
 
           lock->read_wait.data->type < TL_READ_HIGH_PRIORITY))
 
535
          (!lock->read_wait.data || lock->read_wait.data->type <= TL_READ_WITH_SHARED_LOCKS))
552
536
      {
553
537
        if (lock->write_lock_count++ > max_write_lock_count)
554
538
        {
584
568
            break;
585
569
          data=lock->write_wait.data;           /* Free this too */
586
570
        }
587
 
        if (data->type >= TL_WRITE_LOW_PRIORITY)
 
571
        if (data->type >= TL_WRITE)
588
572
          goto end;
589
573
        /* Release possible read locks together with the write lock */
590
574
      }