Changeset 1690

Show
Ignore:
Timestamp:
02/22/2007 01:24:47 PM (20 months ago)
Author:
jan
Message:

expect that read() might return less data than we asked for.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/network_gthread_aio.c

    r1659 r1690  
    8383 
    8484                        c->file.copy.offset = 0; 
    85                         c->file.copy.length = toSend; 
     85                        c->file.copy.length = 0; 
    8686 
    8787                        /* open a file in /dev/shm to write to */ 
     
    9797                                } else { 
    9898                                        c->file.mmap.offset = 0; 
    99                                         c->file.mmap.length = c->file.copy.length; /* align to page-size */ 
     99                                        c->file.mmap.length = toSend; 
    100100         
    101101                                        c->file.mmap.start = mmap(0, c->file.mmap.length, 
     
    111111                 
    112112                        if (c->file.mmap.start != MAP_FAILED) { 
    113                                 lseek(c->file.fd, c->file.start + c->offset, SEEK_SET); 
    114  
    115                                 if (-1 == (r = read(c->file.fd, c->file.mmap.start, c->file.copy.length))) { 
     113                                if (-1 == (r = pread(c->file.fd, c->file.mmap.start, toSend, c->file.start + c->offset))) { 
    116114                                        switch(errno) { 
    117115                                        default: 
     
    121119                                        } 
    122120                                } else if (r == 0) { 
    123                                         ERROR("read() returned 0 ... not good: %s", ""); 
     121                                        ERROR("pread(%s) returned 0 ... not good", BUF_STR(c->file.name)); 
    124122         
    125123                                        c->async.ret_val = NETWORK_STATUS_FATAL_ERROR; 
    126                                 } else if (r != c->file.copy.length) { 
    127                                         ERROR("read() returned %d instead of %d", r, c->file.copy.length); 
    128          
    129                                         c->async.ret_val = NETWORK_STATUS_FATAL_ERROR; 
     124                                } else { 
     125                                        c->file.copy.length = r; 
    130126                                } 
    131127                        }