Additional non-blocking fixes.
Этот коммит содержится в:
родитель
103a6e9e0b
Коммит
75d5830490
@ -1672,8 +1672,8 @@ libssh2_channel_receive_window_adjust2(LIBSSH2_CHANNEL *channel,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
channel_extended_data(LIBSSH2_CHANNEL *channel, int ignore_mode)
|
_libssh2_channel_extended_data(LIBSSH2_CHANNEL *channel, int ignore_mode)
|
||||||
{
|
{
|
||||||
if (channel->extData2_state == libssh2_NB_state_idle) {
|
if (channel->extData2_state == libssh2_NB_state_idle) {
|
||||||
_libssh2_debug(channel->session, LIBSSH2_DBG_CONN,
|
_libssh2_debug(channel->session, LIBSSH2_DBG_CONN,
|
||||||
@ -1708,7 +1708,8 @@ libssh2_channel_handle_extended_data2(LIBSSH2_CHANNEL *channel,
|
|||||||
int mode)
|
int mode)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
BLOCK_ADJUST(rc, channel->session, channel_extended_data(channel, mode));
|
BLOCK_ADJUST(rc, channel->session, _libssh2_channel_extended_data(channel,
|
||||||
|
mode));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,5 +70,8 @@ int _libssh2_channel_flush(LIBSSH2_CHANNEL *channel, int streamid);
|
|||||||
*/
|
*/
|
||||||
int _libssh2_channel_free(LIBSSH2_CHANNEL *channel);
|
int _libssh2_channel_free(LIBSSH2_CHANNEL *channel);
|
||||||
|
|
||||||
|
int
|
||||||
|
_libssh2_channel_extended_data(LIBSSH2_CHANNEL *channel, int ignore_mode);
|
||||||
|
|
||||||
#endif /* __LIBSSH2_CHANNEL_H */
|
#endif /* __LIBSSH2_CHANNEL_H */
|
||||||
|
|
||||||
|
17
src/sftp.c
17
src/sftp.c
@ -36,6 +36,8 @@
|
|||||||
* OF SUCH DAMAGE.
|
* OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "libssh2_priv.h"
|
#include "libssh2_priv.h"
|
||||||
#include "libssh2_sftp.h"
|
#include "libssh2_sftp.h"
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
@ -561,6 +563,8 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
|
|||||||
_libssh2_debug(session, LIBSSH2_DBG_SFTP,
|
_libssh2_debug(session, LIBSSH2_DBG_SFTP,
|
||||||
"Initializing SFTP subsystem");
|
"Initializing SFTP subsystem");
|
||||||
|
|
||||||
|
assert(session->sftpInit_sftp == NULL);
|
||||||
|
|
||||||
session->sftpInit_sftp = NULL;
|
session->sftpInit_sftp = NULL;
|
||||||
|
|
||||||
session->sftpInit_state = libssh2_NB_state_created;
|
session->sftpInit_state = libssh2_NB_state_created;
|
||||||
@ -575,14 +579,13 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
|
|||||||
if (libssh2_session_last_errno(session) == LIBSSH2_ERROR_EAGAIN) {
|
if (libssh2_session_last_errno(session) == LIBSSH2_ERROR_EAGAIN) {
|
||||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||||
"Would block starting up channel", 0);
|
"Would block starting up channel", 0);
|
||||||
return NULL;
|
}
|
||||||
} else if (libssh2_session_last_errno(session) !=
|
else {
|
||||||
LIBSSH2_ERROR_EAGAIN) {
|
|
||||||
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
|
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
|
||||||
"Unable to startup channel", 0);
|
"Unable to startup channel", 0);
|
||||||
session->sftpInit_state = libssh2_NB_state_idle;
|
session->sftpInit_state = libssh2_NB_state_idle;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
session->sftpInit_state = libssh2_NB_state_sent;
|
session->sftpInit_state = libssh2_NB_state_sent;
|
||||||
@ -607,8 +610,8 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (session->sftpInit_state == libssh2_NB_state_sent1) {
|
if (session->sftpInit_state == libssh2_NB_state_sent1) {
|
||||||
rc = libssh2_channel_handle_extended_data2(session->sftpInit_channel,
|
rc = _libssh2_channel_extended_data(session->sftpInit_channel,
|
||||||
LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE);
|
LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE);
|
||||||
if (rc == PACKET_EAGAIN) {
|
if (rc == PACKET_EAGAIN) {
|
||||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||||
"Would block requesting handle extended data", 0);
|
"Would block requesting handle extended data", 0);
|
||||||
@ -709,7 +712,7 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
|
|||||||
return session->sftpInit_sftp;
|
return session->sftpInit_sftp;
|
||||||
|
|
||||||
sftp_init_error:
|
sftp_init_error:
|
||||||
while (libssh2_channel_free(session->sftpInit_channel) == PACKET_EAGAIN);
|
while (_libssh2_channel_free(session->sftpInit_channel) == PACKET_EAGAIN);
|
||||||
session->sftpInit_channel = NULL;
|
session->sftpInit_channel = NULL;
|
||||||
if (session->sftpInit_sftp) {
|
if (session->sftpInit_sftp) {
|
||||||
LIBSSH2_FREE(session, session->sftpInit_sftp);
|
LIBSSH2_FREE(session, session->sftpInit_sftp);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user