~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/thr_lock.c

  • Committer: Brian Aker
  • Date: 2008-07-13 18:27:33 UTC
  • Revision ID: brian@tangent.org-20080713182733-3u1et5nrmofi8a8n
my_bool cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
#include <m_string.h>
81
81
#include <errno.h>
82
82
 
83
 
my_bool thr_lock_inited=0;
 
83
bool thr_lock_inited=0;
84
84
ulong locks_immediate = 0L, locks_waited = 0L;
85
85
ulong table_lock_wait_timeout;
86
86
enum thr_lock_type thr_upgraded_concurrent_insert_lock = TL_WRITE;
102
102
** For the future (now the thread specific cond is alloced by my_pthread.c)
103
103
*/
104
104
 
105
 
my_bool init_thr_lock()
 
105
bool init_thr_lock()
106
106
{
107
107
  thr_lock_inited=1;
108
108
  return 0;
109
109
}
110
110
 
111
 
static inline my_bool
 
111
static inline bool
112
112
thr_lock_owner_equal(THR_LOCK_OWNER *rhs, THR_LOCK_OWNER *lhs)
113
113
{
114
114
  return rhs == lhs;
120
120
static uint found_errors=0;
121
121
 
122
122
static int check_lock(struct st_lock_list *list, const char* lock_type,
123
 
                      const char *where, my_bool same_owner, my_bool no_cond)
 
123
                      const char *where, bool same_owner, bool no_cond)
124
124
{
125
125
  THR_LOCK_DATA *data,**prev;
126
126
  uint count=0;
180
180
 
181
181
 
182
182
static void check_locks(THR_LOCK *lock, const char *where,
183
 
                        my_bool allow_no_locks)
 
183
                        bool allow_no_locks)
184
184
{
185
185
  uint old_found_errors=found_errors;
186
186
  DBUG_ENTER("check_locks");
359
359
}
360
360
 
361
361
 
362
 
static inline my_bool
 
362
static inline bool
363
363
have_old_read_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner)
364
364
{
365
365
  for ( ; data ; data=data->next)
370
370
  return 0;
371
371
}
372
372
 
373
 
static inline my_bool have_specific_lock(THR_LOCK_DATA *data,
 
373
static inline bool have_specific_lock(THR_LOCK_DATA *data,
374
374
                                         enum thr_lock_type type)
375
375
{
376
376
  for ( ; data ; data=data->next)
387
387
 
388
388
static enum enum_thr_lock_result
389
389
wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
390
 
              my_bool in_wait_list)
 
390
              bool in_wait_list)
391
391
{
392
392
  struct st_my_thread_var *thread_var= my_thread_var;
393
393
  pthread_cond_t *cond= &thread_var->suspend;
394
394
  struct timespec wait_timeout;
395
395
  enum enum_thr_lock_result result= THR_LOCK_ABORTED;
396
 
  my_bool can_deadlock= test(data->owner->info->n_cursors);
 
396
  bool can_deadlock= test(data->owner->info->n_cursors);
397
397
  DBUG_ENTER("wait_for_lock");
398
398
 
399
399
  if (!in_wait_list)
653
653
                          (ulong) lock->write_wait.data));
654
654
      if (!lock->write_wait.data)
655
655
      {                                         /* no scheduled write locks */
656
 
        my_bool concurrent_insert= 0;
 
656
        bool concurrent_insert= 0;
657
657
        if (lock_type == TL_WRITE_CONCURRENT_INSERT)
658
658
        {
659
659
          concurrent_insert= 1;
707
707
 
708
708
 
709
709
static inline void free_all_read_locks(THR_LOCK *lock,
710
 
                                       my_bool using_concurrent_insert)
 
710
                                       bool using_concurrent_insert)
711
711
{
712
712
  THR_LOCK_DATA *data=lock->read_wait.data;
713
713
 
1061
1061
  TL_WRITE_ONLY to abort any new accesses to the lock
1062
1062
*/
1063
1063
 
1064
 
void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock)
 
1064
void thr_abort_locks(THR_LOCK *lock, bool upgrade_lock)
1065
1065
{
1066
1066
  THR_LOCK_DATA *data;
1067
1067
  DBUG_ENTER("thr_abort_locks");
1096
1096
  This is used to abort all locks for a specific thread
1097
1097
*/
1098
1098
 
1099
 
my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
 
1099
bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
1100
1100
{
1101
1101
  THR_LOCK_DATA *data;
1102
 
  my_bool found= FALSE;
 
1102
  bool found= FALSE;
1103
1103
  DBUG_ENTER("thr_abort_locks_for_thread");
1104
1104
 
1105
1105
  pthread_mutex_lock(&lock->mutex);
1193
1193
 
1194
1194
/* Upgrade a WRITE_DELAY lock to a WRITE_LOCK */
1195
1195
 
1196
 
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
 
1196
bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
1197
1197
{
1198
1198
  THR_LOCK *lock=data->lock;
1199
1199
  DBUG_ENTER("thr_upgrade_write_delay_lock");
1242
1242
 
1243
1243
/* downgrade a WRITE lock to a WRITE_DELAY lock if there is pending locks */
1244
1244
 
1245
 
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
 
1245
bool thr_reschedule_write_lock(THR_LOCK_DATA *data)
1246
1246
{
1247
1247
  THR_LOCK *lock=data->lock;
1248
1248
  DBUG_ENTER("thr_reschedule_write_lock");
1414
1414
{
1415
1415
}
1416
1416
 
1417
 
static my_bool test_check_status(void* param __attribute__((unused)))
 
1417
static bool test_check_status(void* param __attribute__((unused)))
1418
1418
{
1419
1419
  return 0;
1420
1420
}