Reduce busy-looping of libssh2_sftp_packet_requirev()

This commit is contained in:
Sara Golemon 2005-05-16 23:12:09 +00:00
parent 8d90bbfc28
commit 30bb7db0d1
2 changed files with 12 additions and 1 deletions

2
README
View File

@ -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
-----------

View File

@ -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;