mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-23 01:22:37 +03:00
read_state: clear the state variable better
Set read_state back to idle before trying to send anything so that if the state somehow is wrongly set. Also, avoid such a case of confusion by resetting the read_state when an sftp handle is closed.
This commit is contained in:
@@ -1210,12 +1210,13 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
|||||||
as possible - remember that we don't block */
|
as possible - remember that we don't block */
|
||||||
chunk = _libssh2_list_first(&handle->packet_list);
|
chunk = _libssh2_list_first(&handle->packet_list);
|
||||||
|
|
||||||
|
sftp->read_state = libssh2_NB_state_idle;
|
||||||
|
|
||||||
while(chunk) {
|
while(chunk) {
|
||||||
if(chunk->lefttosend) {
|
if(chunk->lefttosend) {
|
||||||
rc = _libssh2_channel_write(channel, 0,
|
rc = _libssh2_channel_write(channel, 0,
|
||||||
&chunk->packet[chunk->sent],
|
&chunk->packet[chunk->sent],
|
||||||
chunk->lefttosend);
|
chunk->lefttosend);
|
||||||
sftp->read_state = libssh2_NB_state_idle;
|
|
||||||
if(rc < 0) {
|
if(rc < 0) {
|
||||||
if(rc != LIBSSH2_ERROR_EAGAIN)
|
if(rc != LIBSSH2_ERROR_EAGAIN)
|
||||||
/* error */
|
/* error */
|
||||||
@@ -2087,6 +2088,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sftp_packetlist_flush(handle);
|
sftp_packetlist_flush(handle);
|
||||||
|
sftp->read_state = libssh2_NB_state_idle;
|
||||||
|
|
||||||
handle->close_state = libssh2_NB_state_idle;
|
handle->close_state = libssh2_NB_state_idle;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user