~hartmut-php/drizzle/codestyle

« back to all changes in this revision

Viewing changes to mysys/thr_lock.c

  • Committer: Monty Taylor
  • Date: 2008-08-10 16:52:18 UTC
  • mfrom: (293 drizzle)
  • mto: (312.1.3 translations)
  • mto: This revision was merged to the branch mainline in revision 295.
  • Revision ID: monty@inaugust.com-20080810165218-jlekj1n46oyx9sih
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1200
1200
 
1201
1201
#include <my_sys.h>
1202
1202
 
1203
 
static void thr_print_lock(const char* name,struct st_lock_list *list)
1204
 
{
1205
 
  THR_LOCK_DATA *data,**prev;
1206
 
  uint count=0;
1207
 
 
1208
 
  if (list->data)
1209
 
  {
1210
 
    printf("%-10s: ",name);
1211
 
    prev= &list->data;
1212
 
    for (data=list->data; data && count++ < MAX_LOCKS ; data=data->next)
1213
 
    {
1214
 
      printf("0x%lx (%lu:%d); ", (ulong) data, data->owner->info->thread_id,
1215
 
             (int) data->type);
1216
 
      if (data->prev != prev)
1217
 
        printf("\nWarning: prev didn't point at previous lock\n");
1218
 
      prev= &data->next;
1219
 
    }
1220
 
    puts("");
1221
 
    if (prev != list->last)
1222
 
      printf("Warning: last didn't point at last lock\n");
1223
 
  }
1224
 
}
1225
 
 
1226
 
void thr_print_locks(void)
1227
 
{
1228
 
  LIST *list;
1229
 
  uint count=0;
1230
 
 
1231
 
  pthread_mutex_lock(&THR_LOCK_lock);
1232
 
  puts("Current locks:");
1233
 
  for (list= thr_lock_thread_list; list && count++ < MAX_THREADS;
1234
 
       list= list_rest(list))
1235
 
  {
1236
 
    THR_LOCK *lock=(THR_LOCK*) list->data;
1237
 
    VOID(pthread_mutex_lock(&lock->mutex));
1238
 
    printf("lock: 0x%lx:",(ulong) lock);
1239
 
    if ((lock->write_wait.data || lock->read_wait.data) &&
1240
 
        (! lock->read.data && ! lock->write.data))
1241
 
      printf(" WARNING: ");
1242
 
    if (lock->write.data)
1243
 
      printf(" write");
1244
 
    if (lock->write_wait.data)
1245
 
      printf(" write_wait");
1246
 
    if (lock->read.data)
1247
 
      printf(" read");
1248
 
    if (lock->read_wait.data)
1249
 
      printf(" read_wait");
1250
 
    puts("");
1251
 
    thr_print_lock("write",&lock->write);
1252
 
    thr_print_lock("write_wait",&lock->write_wait);
1253
 
    thr_print_lock("read",&lock->read);
1254
 
    thr_print_lock("read_wait",&lock->read_wait);
1255
 
    VOID(pthread_mutex_unlock(&lock->mutex));
1256
 
    puts("");
1257
 
  }
1258
 
  fflush(stdout);
1259
 
  pthread_mutex_unlock(&THR_LOCK_lock);
1260
 
}
1261
 
 
1262
1203
/*****************************************************************************
1263
1204
** Test of thread locks
1264
1205
****************************************************************************/