~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mf_keycache.c

  • Committer: Monty Taylor
  • Date: 2008-10-16 09:12:23 UTC
  • mto: (511.1.6 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016091223-17ngih0qu9vssjs3
We pass -Wunused-macros now!

Show diffs side-by-side

added added

removed removed

Lines of Context:
143
143
/* types of condition variables */
144
144
#define  COND_FOR_REQUESTED 0
145
145
#define  COND_FOR_SAVED     1
146
 
#define  COND_FOR_READERS   2
147
146
 
148
147
typedef pthread_cond_t KEYCACHE_CONDVAR;
149
148
 
220
219
                                     (uint32_t) (f)) & (keycache->hash_entries-1))
221
220
#define FILE_HASH(f)                 ((uint) (f) & (CHANGED_BLOCKS_HASH-1))
222
221
 
223
 
#define BLOCK_NUMBER(b)                                                       \
224
 
  ((uint) (((char*)(b)-(char *) keycache->block_root)/sizeof(BLOCK_LINK)))
225
 
#define HASH_LINK_NUMBER(h)                                                   \
226
 
  ((uint) (((char*)(h)-(char *) keycache->hash_link_root)/sizeof(HASH_LINK)))
227
222
 
228
223
#ifdef KEYCACHE_TIMEOUT
229
224
static int keycache_pthread_cond_wait(pthread_cond_t *cond,
3772
3767
 
3773
3768
#if defined(KEYCACHE_TIMEOUT)
3774
3769
 
 
3770
 
 
3771
static inline
 
3772
unsigned int hash_link_number(HASH_LINK *hash_link, KEY_CACHE *keycache)
 
3773
{
 
3774
  return ((unsigned int) (((char*)hash_link-(char *) keycache->hash_link_root)/
 
3775
                  sizeof(HASH_LINK)));
 
3776
}
 
3777
 
 
3778
static inline
 
3779
unsigned int block_number(BLOCK_LINK *block, KEY_CACHE *keycache)
 
3780
{
 
3781
  return ((unsigned int) (((char*)block-(char *)keycache->block_root)/
 
3782
                  sizeof(BLOCK_LINK)));
 
3783
}
 
3784
 
 
3785
 
3775
3786
#define KEYCACHE_DUMP_FILE  "keycache_dump.txt"
3776
3787
#define MAX_QUEUE_LEN  100
3777
3788
 
3813
3824
      thread=thread->next;
3814
3825
      hash_link= (HASH_LINK *) thread->opt_info;
3815
3826
      fprintf(keycache_dump_file,
3816
 
        "thread:%u hash_link:%u (file,filepos)=(%u,%u)\n",
3817
 
        thread->id, (uint) HASH_LINK_NUMBER(hash_link),
3818
 
        (uint) hash_link->file,(uint32_t) hash_link->diskpos);
 
3827
              "thread:%u hash_link:%u (file,filepos)=(%u,%u)\n",
 
3828
              thread->id, (uint) hash_link_number(hash_link, keycache),
 
3829
              (uint) hash_link->file,(uint32_t) hash_link->diskpos);
3819
3830
      if (++i == MAX_QUEUE_LEN)
3820
3831
        break;
3821
3832
    }
3827
3838
    block= &keycache->block_root[i];
3828
3839
    hash_link= block->hash_link;
3829
3840
    fprintf(keycache_dump_file,
3830
 
            "block:%u hash_link:%d status:%x #requests=%u waiting_for_readers:%d\n",
3831
 
            i, (int) (hash_link ? HASH_LINK_NUMBER(hash_link) : -1),
3832
 
            block->status, block->requests, block->condvar ? 1 : 0);
 
3841
            "block:%u hash_link:%d status:%x #requests=%u "
 
3842
            "waiting_for_readers:%d\n",
 
3843
            i, (int) (hash_link ? hash_link_number(hash_link, keycache) : -1),
 
3844
            block->status, block->requests, block->condvar ? 1 : 0);
3833
3845
    for (j=0 ; j < 2; j++)
3834
3846
    {
3835
3847
      KEYCACHE_WQUEUE *wqueue=&block->wqueue[j];
3857
3869
    {
3858
3870
      block= block->next_used;
3859
3871
      fprintf(keycache_dump_file,
3860
 
              "block:%u, ", BLOCK_NUMBER(block));
 
3872
              "block:%u, ", block_number(block, keycache));
3861
3873
    }
3862
3874
    while (block != keycache->used_last);
3863
3875
  }