Reduce busy-looping of libssh2_sftp_packet_requirev()
This commit is contained in:
parent
8d90bbfc28
commit
30bb7db0d1
2
README
2
README
@ -14,6 +14,8 @@ Version 0.10
|
||||
|
||||
Fixed segfault when client and host can't agree on a hostkey/crypt/mac/comp method. (Thanks puudeli)
|
||||
|
||||
Reduced busy-looping of libssh2_sftp_packet_requirev.
|
||||
|
||||
Version 0.9
|
||||
-----------
|
||||
|
||||
|
11
src/sftp.c
11
src/sftp.c
@ -306,12 +306,21 @@ static int libssh2_sftp_packet_requirev(LIBSSH2_SFTP *sftp, int num_valid_respon
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Flush */
|
||||
while (libssh2_sftp_packet_read(sftp, 0) > 0);
|
||||
|
||||
while (sftp->channel->session->socket_state == LIBSSH2_SOCKET_CONNECTED) {
|
||||
int ret;
|
||||
for(i = 0; i < num_valid_responses; i++) {
|
||||
if (libssh2_sftp_packet_ask(sftp, valid_responses[i], request_id, data, data_len, !i) == 0) {
|
||||
if (libssh2_sftp_packet_ask(sftp, valid_responses[i], request_id, data, data_len, 0) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ret = libssh2_sftp_packet_read(sftp, 1);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (ret == 0) continue;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user