Show
Ignore:
Timestamp:
08/06/05 04:33:10 (5 years ago)
Author:
bradfitz
Message:

make Perlbal::AIO's aio_{read|write} not change the $fh's offset, ala
pread/pwrite, as used by {Linux,IO}::AIO

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/Perlbal/AIO.pm

    r359 r380  
    55 
    66package Perlbal::AIO; 
    7 use POSIX qw(); 
     7 
     8use Fcntl qw(SEEK_CUR SEEK_SET SEEK_END); 
    89 
    910sub aio_stat { 
     
    6970        IO::AIO::aio_write($fh, $offset, $length, $_[3], 0, $cb); 
    7071    } else { 
     72        my $old_off = sysseek($fh, 0, SEEK_CUR); 
    7173        sysseek($fh, $offset, 0); 
    7274        my $rv = syswrite($fh, $_[3], $length, 0); 
     75        sysseek($fh, $old_off, SEEK_SET); 
    7376        $cb->($rv); 
    7477    } 
     
    8588        IO::AIO::aio_read($fh, $offset, $length, $_[3], 0, $cb); 
    8689    } else { 
     90        my $old_off = sysseek($fh, 0, SEEK_CUR); 
    8791        sysseek($fh, $offset, 0); 
    8892        my $rv = sysread($fh, $_[3], $length, 0); 
     93        sysseek($fh, $old_off, SEEK_SET); 
    8994        $cb->($rv); 
    9095    }