|
|
68eb44 |
From 486bb376218a37fe15318d7724d6eada36b81e6c Mon Sep 17 00:00:00 2001
|
|
|
68eb44 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
68eb44 |
Date: Tue, 26 Mar 2013 17:58:04 +0100
|
|
|
68eb44 |
Subject: [PATCH 1/3] sftp: seek: Don't flush buffers on same offset
|
|
|
68eb44 |
|
|
|
68eb44 |
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
68eb44 |
---
|
|
|
68eb44 |
src/sftp.c | 27 +++++++++++++++------------
|
|
|
68eb44 |
1 file changed, 15 insertions(+), 12 deletions(-)
|
|
|
68eb44 |
|
|
|
68eb44 |
diff --git a/src/sftp.c b/src/sftp.c
|
|
|
68eb44 |
index d0536dd..3760025 100644
|
|
|
68eb44 |
--- a/src/sftp.c
|
|
|
68eb44 |
+++ b/src/sftp.c
|
|
|
68eb44 |
@@ -2132,21 +2132,24 @@ libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *hnd,
|
|
|
68eb44 |
LIBSSH2_API void
|
|
|
68eb44 |
libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset)
|
|
|
68eb44 |
{
|
|
|
68eb44 |
- if(handle) {
|
|
|
68eb44 |
- handle->u.file.offset = handle->u.file.offset_sent = offset;
|
|
|
68eb44 |
- /* discard all pending requests and currently read data */
|
|
|
68eb44 |
- sftp_packetlist_flush(handle);
|
|
|
68eb44 |
+ if(!handle)
|
|
|
68eb44 |
+ return;
|
|
|
68eb44 |
+ if(handle->u.file.offset == offset && handle->u.file.offset_sent == offset)
|
|
|
68eb44 |
+ return;
|
|
|
68eb44 |
|
|
|
68eb44 |
- /* free the left received buffered data */
|
|
|
68eb44 |
- if (handle->u.file.data_left) {
|
|
|
68eb44 |
- LIBSSH2_FREE(handle->sftp->channel->session, handle->u.file.data);
|
|
|
68eb44 |
- handle->u.file.data_left = handle->u.file.data_len = 0;
|
|
|
68eb44 |
- handle->u.file.data = NULL;
|
|
|
68eb44 |
- }
|
|
|
68eb44 |
+ handle->u.file.offset = handle->u.file.offset_sent = offset;
|
|
|
68eb44 |
+ /* discard all pending requests and currently read data */
|
|
|
68eb44 |
+ sftp_packetlist_flush(handle);
|
|
|
68eb44 |
|
|
|
68eb44 |
- /* reset EOF to False */
|
|
|
68eb44 |
- handle->u.file.eof = FALSE;
|
|
|
68eb44 |
+ /* free the left received buffered data */
|
|
|
68eb44 |
+ if (handle->u.file.data_left) {
|
|
|
68eb44 |
+ LIBSSH2_FREE(handle->sftp->channel->session, handle->u.file.data);
|
|
|
68eb44 |
+ handle->u.file.data_left = handle->u.file.data_len = 0;
|
|
|
68eb44 |
+ handle->u.file.data = NULL;
|
|
|
68eb44 |
}
|
|
|
68eb44 |
+
|
|
|
68eb44 |
+ /* reset EOF to False */
|
|
|
68eb44 |
+ handle->u.file.eof = FALSE;
|
|
|
68eb44 |
}
|
|
|
68eb44 |
|
|
|
68eb44 |
/* libssh2_sftp_seek
|
|
|
68eb44 |
--
|
|
|
68eb44 |
1.8.1.4
|
|
|
68eb44 |
|