Subject: Re: sftp_read retuning 0 prematurely

Re: sftp_read retuning 0 prematurely

From: Daniel Stenberg <>
Date: Sun, 4 Sep 2011 19:03:18 +0200 (CEST)

On Sun, 4 Sep 2011, Alexander Lamaison wrote:

> Ah, I'm with you now. At the same time as fixing this, we may need to
> add some more comments :P

I agree. I'll make sure to add some explanations.

> This patch fixes it for me :)

Good! Then we at least know we're on the right track.

>> On a second thought, that's too simple and will make a 'gap' in the file...
>> I'll have to think a while more and provide a better patch soon.
> You mean where later SFTP_READs were sent out requesting data from the full
> chunk->len offset onwards?


We ask for two parts A + B where each part is size 'len', and when we get 'A'
it is shorter than expected. We must then ask for the remainder of part 'A' so
there won't be a gap until we get part B.

> But now we need to make another request for the range between (chunk->len -
> rc32) and chunk->len? Can we just send out another SFTP_READ requesting
> this or do they have to be sent sequentially?

We can indeed send away another READ request for that part, they're completely
independent of each other, we just need to carefully make sure that libssh2
will wait for that part next to insert into the buffer, before the parts that
it already asked for...

Received on 2011-09-04