1
1

libssh2_sftp_seek64: flush packetlist and buffered data

When seeking to a new position, flush the packetlist and buffered data
to prevent already received or pending data to wrongly get used when
sftp-reading from the new offset within the file.
Этот коммит содержится в:
liuzl 2011-08-26 13:47:35 +02:00 коммит произвёл Daniel Stenberg
родитель 900c90ccbe
Коммит 8c0294db66

Просмотреть файл

@ -1859,8 +1859,18 @@ libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *hnd,
LIBSSH2_API void
libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset)
{
if(handle)
if(handle) {
handle->u.file.offset = handle->u.file.offset_sent = offset;
/* discard all pending requests and currently read data */
sftp_packetlist_flush(handle);
/* free the left received buffered data */
if (handle->u.file.data_left) {
LIBSSH2_FREE(handle->sftp->channel->session, handle->u.file.data);
handle->u.file.data_left = handle->u.file.data_len = 0;
handle->u.file.data = NULL;
}
}
}
/* libssh2_sftp_seek