On 26/07/2025 06:03, Eshan Kelkar wrote:
Hi Edrusb,
Hi Eshan,
Thank you for your quick and clear response!
[...]
Or is there some reason (that I am overlooking) due to which this
could not be done in your case (or does not work ?) ?
Everything works fine, no worries! I was just not aware of the
blocking/no-blocking mode of sftp_aio_wait_read() function, and wondered
how to deal with possible situation of SSH_AGAIN returned code.
Or, asked another way: when sftp_aio_wait_read() returns
SSH_AGAIN, can
a program call it again right away as there is no chance it returns
again SSH_AGAIN and thus there is no need to wait/sleep for some time
between calls in that context, to avoid wasting CPU cycles and
creating
unnecessary load on the system?
Yes, a program can call sftp_aio_wait_read() again right away after it
returns. However, when such blocking behaviour is needed, it is
recommended to use the aforementioned approach instead, i.e:
1. Open a sftp_file in blocking mode (default) or set to blocking mode
using sftp_file_set_blocking()
2. Call sftp_aio_wait_read() which should wait (or will report
failure) till expected data comes.
If the blocking mode is the default, that's fine, as I have not changed
it that's what I'm using. And thus, I understand that in that mode I
should not be worried by a returned code of SSH_AGAIN, perfect!
I would suggest adding a note in the sftp_aio_wait_*() documentation
telling that SSH_AGAIN is only returned in non-blocking mode and add
also a pointer to the sftp_file_set_blocking()/nonblocking() functions.
My 2 cents ;)
[...]
Regards,
Eshan Kelkar
Best Regards,
Edrusb