Skip to content
  • Harald Sitter's avatar
    sftp: fix offset handling on short reads · cfa52aed
    Harald Sitter authored
    reads that came back with less data are fairly garbage to handle.
    
    the offset is increased when we make requests with read_begin so the
    original offset when we enter readchunks is the offset as if all pending
    requests had returned.
    async_read reduces that offset when a request cames back short.
    since we still want the missing data we make a new request for the
    missing data both we and libssh modify the offset as part of that
    re-requesting.
    after that dance we need to restore the most original offset to restore
    that initial condition where the offset is the offset as though all
    requests had returned. it remains unchanged because we've re-queued the
    missing data
    
    the original code lacked this offset restoring which meant that if we
    had a short request in the middle of a file it'd break the offset,
    return, the caller would queue more chunks and those chunsk would all
    have wrong offsets now: increasing from (missingoffset + missingsize) up
    to file.size **duplicating** whatever requests may still be pending at
    that time.
    cfa52aed