sftp_write: don't return EAGAIN if no EAGAIN was received
This function now only returns EAGAIN if a lower layer actually returned EAGAIN to it. If nothing was acked and no EAGAIN was received, it will now instead return 0.
Этот коммит содержится в:
родитель
095e9e7b3e
Коммит
2dfa5d38cb
14
src/sftp.c
14
src/sftp.c
@ -1435,6 +1435,7 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
|||||||
size_t sent = 0;
|
size_t sent = 0;
|
||||||
size_t acked = 0;
|
size_t acked = 0;
|
||||||
size_t org_count = count;
|
size_t org_count = count;
|
||||||
|
size_t eagain = 0;
|
||||||
|
|
||||||
/* number of bytes sent off that haven't been acked and therefor
|
/* number of bytes sent off that haven't been acked and therefor
|
||||||
we will get passed in here again */
|
we will get passed in here again */
|
||||||
@ -1496,6 +1497,7 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
|||||||
if(rc != LIBSSH2_ERROR_EAGAIN)
|
if(rc != LIBSSH2_ERROR_EAGAIN)
|
||||||
/* error */
|
/* error */
|
||||||
return rc;
|
return rc;
|
||||||
|
eagain++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1527,8 +1529,10 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
|||||||
/* we can expect the packets to be ACKed in order */
|
/* we can expect the packets to be ACKed in order */
|
||||||
rc = sftp_packet_require(sftp, SSH_FXP_STATUS,
|
rc = sftp_packet_require(sftp, SSH_FXP_STATUS,
|
||||||
chunk->request_id, &data, &data_len);
|
chunk->request_id, &data, &data_len);
|
||||||
if (rc == LIBSSH2_ERROR_EAGAIN)
|
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||||
|
eagain++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
else if (rc) {
|
else if (rc) {
|
||||||
sftp->write_state = libssh2_NB_state_idle;
|
sftp->write_state = libssh2_NB_state_idle;
|
||||||
return _libssh2_error(session, rc, "Waiting for SFTP status");
|
return _libssh2_error(session, rc, "Waiting for SFTP status");
|
||||||
@ -1563,9 +1567,11 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
|||||||
/* we got data acked so return that amount, but no more than what
|
/* we got data acked so return that amount, but no more than what
|
||||||
was asked to get sent! */
|
was asked to get sent! */
|
||||||
return MIN(acked, org_count);
|
return MIN(acked, org_count);
|
||||||
|
else if(eagain)
|
||||||
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||||
"Would block");
|
"Would block sftp_write");
|
||||||
|
else
|
||||||
|
return 0; /* nothing was acked, and no EAGAIN was received! */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libssh2_sftp_write
|
/* libssh2_sftp_write
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user