~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_keycache.c

  • Committer: Brian Aker
  • Date: 2008-07-01 20:14:24 UTC
  • Revision ID: brian@tangent.org-20080701201424-rsof5enxl7gkr50p
More cleanup on pread()

Show diffs side-by-side

added added

removed removed

Lines of Context:
2205
2205
                The call is thread safe because only the current
2206
2206
                thread might change the block->hash_link value
2207
2207
              */
2208
 
              error= my_pwrite(block->hash_link->file,
2209
 
                               block->buffer+block->offset,
2210
 
                               block->length - block->offset,
2211
 
                               block->hash_link->diskpos+ block->offset,
2212
 
                               MYF(MY_NABP | MY_WAIT_IF_FULL));
 
2208
              error= (pwrite(block->hash_link->file,
 
2209
                             block->buffer+block->offset,
 
2210
                             block->length - block->offset,
 
2211
                             block->hash_link->diskpos+ block->offset) == 0);
2213
2212
              keycache_pthread_mutex_lock(&keycache->cache_lock);
2214
2213
 
2215
2214
              /* Block status must not have changed. */
2432
2431
      Here other threads may step in and register as secondary readers.
2433
2432
      They will register in block->wqueue[COND_FOR_REQUESTED].
2434
2433
    */
2435
 
    got_length= my_pread(block->hash_link->file, block->buffer,
2436
 
                         read_length, block->hash_link->diskpos, MYF(0));
 
2434
    got_length= pread(block->hash_link->file, block->buffer, read_length, block->hash_link->diskpos);
2437
2435
    keycache_pthread_mutex_lock(&keycache->cache_lock);
2438
2436
    /*
2439
2437
      The block can now have been marked for free (in case of
2594
2592
        */
2595
2593
        keycache->global_cache_read++;
2596
2594
        keycache_pthread_mutex_unlock(&keycache->cache_lock);
2597
 
        error= (my_pread(file, (uchar*) buff, read_length,
2598
 
                         filepos + offset, MYF(MY_NABP)) != 0);
 
2595
        error= (pread(file, (uchar*) buff, read_length, filepos + offset) == 0);
2599
2596
        keycache_pthread_mutex_lock(&keycache->cache_lock);
2600
2597
        goto next_block;
2601
2598
      }
2690
2687
 
2691
2688
  if (locked_and_incremented)
2692
2689
    keycache_pthread_mutex_unlock(&keycache->cache_lock);
2693
 
  if (my_pread(file, (uchar*) buff, length, filepos, MYF(MY_NABP)))
 
2690
  if (pread(file, (uchar*) buff, length, filepos))
2694
2691
    error= 1;
2695
2692
  if (locked_and_incremented)
2696
2693
    keycache_pthread_mutex_lock(&keycache->cache_lock);
2989
2986
    /* Force writing from buff into disk. */
2990
2987
    keycache->global_cache_w_requests++;
2991
2988
    keycache->global_cache_write++;
2992
 
    if (my_pwrite(file, buff, length, filepos, MYF(MY_NABP | MY_WAIT_IF_FULL)))
 
2989
    if (pwrite(file, buff, length, filepos) == 0)
2993
2990
      DBUG_RETURN(1);
2994
2991
    /* purecov: end */
2995
2992
  }
3064
3061
          /* Used in the server. */
3065
3062
          keycache->global_cache_write++;
3066
3063
          keycache_pthread_mutex_unlock(&keycache->cache_lock);
3067
 
          if (my_pwrite(file, (uchar*) buff, read_length, filepos + offset,
3068
 
                        MYF(MY_NABP | MY_WAIT_IF_FULL)))
 
3064
          if (pwrite(file, (uchar*) buff, read_length, filepos + offset) == 0)
3069
3065
            error=1;
3070
3066
          keycache_pthread_mutex_lock(&keycache->cache_lock);
3071
3067
        }
3232
3228
    keycache->global_cache_write++;
3233
3229
    if (locked_and_incremented)
3234
3230
      keycache_pthread_mutex_unlock(&keycache->cache_lock);
3235
 
    if (my_pwrite(file, (uchar*) buff, length, filepos,
3236
 
                  MYF(MY_NABP | MY_WAIT_IF_FULL)))
 
3231
    if (pwrite(file, (uchar*) buff, length, filepos) == 0)
3237
3232
      error=1;
3238
3233
    if (locked_and_incremented)
3239
3234
      keycache_pthread_mutex_lock(&keycache->cache_lock);
3459
3454
                  (BLOCK_READ | BLOCK_IN_FLUSH | BLOCK_CHANGED | BLOCK_IN_USE));
3460
3455
      block->status|= BLOCK_IN_FLUSHWRITE;
3461
3456
      keycache_pthread_mutex_unlock(&keycache->cache_lock);
3462
 
      error= my_pwrite(file,
3463
 
                       block->buffer+block->offset,
3464
 
                       block->length - block->offset,
3465
 
                       block->hash_link->diskpos+ block->offset,
3466
 
                       MYF(MY_NABP | MY_WAIT_IF_FULL));
 
3457
      error= (pwrite(file,
 
3458
                     block->buffer+block->offset,
 
3459
                     block->length - block->offset,
 
3460
                     block->hash_link->diskpos+ block->offset) == 0);
3467
3461
      keycache_pthread_mutex_lock(&keycache->cache_lock);
3468
3462
      keycache->global_cache_write++;
3469
3463
      if (error)