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:
parent
33865b8936
commit
4b77724b3b
@ -1210,12 +1210,13 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
as possible - remember that we don't block */
|
||||
chunk = _libssh2_list_first(&handle->packet_list);
|
||||
|
||||
sftp->read_state = libssh2_NB_state_idle;
|
||||
|
||||
while(chunk) {
|
||||
if(chunk->lefttosend) {
|
||||
rc = _libssh2_channel_write(channel, 0,
|
||||
&chunk->packet[chunk->sent],
|
||||
chunk->lefttosend);
|
||||
sftp->read_state = libssh2_NB_state_idle;
|
||||
if(rc < 0) {
|
||||
if(rc != LIBSSH2_ERROR_EAGAIN)
|
||||
/* error */
|
||||
@ -2087,6 +2088,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
|
||||
}
|
||||
|
||||
sftp_packetlist_flush(handle);
|
||||
sftp->read_state = libssh2_NB_state_idle;
|
||||
|
||||
handle->close_state = libssh2_NB_state_idle;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user